Package com.norconex.importer.charset
Class CharsetUtil
java.lang.Object
com.norconex.importer.charset.CharsetUtil
Character set utility methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidconvertCharset(@NonNull InputStream input, @NonNull Charset inputCharset, @NonNull OutputStream output, @NonNull Charset outputCharset) Converts the character encoding of the supplied input.static voidconvertCharset(InputStream input, String inputCharset, OutputStream output, String outputCharset) Converts the character encoding of the supplied input.static StringconvertCharset(String input, String inputCharset, String outputCharset) Converts the character encoding of the supplied input value.static StringconvertCharset(String input, @NonNull Charset inputCharset, @NonNull Charset outputCharset) Converts the character encoding of the supplied input value.static StringfirstNonBlankOrUTF8(ParseState parseState, String... charsets) Returns the first non-blank character encoding, or returns UTF-8 if they are all blank or in post-parse state.static StringfirstNonBlankOrUTF8(String... charsets) Returns the first non-blank character encoding, or returns UTF-8 if they are all blank.static CharsetfirstNonNullOrUTF8(ParseState parseState, Charset... charsets) Returns the first non-blank character encoding, or returns UTF-8 if they are all blank or in post-parse state.static CharsetfirstNonNullOrUTF8(Charset... charsets) Returns the first non-blank character encoding, or returns UTF-8 if they are all blank.
-
Method Details
-
convertCharset
public static String convertCharset(String input, @NonNull @NonNull Charset inputCharset, @NonNull @NonNull Charset outputCharset) throws IOException Converts the character encoding of the supplied input value.- Parameters:
input- input value to apply conversioninputCharset- character set of the input valueoutputCharset- desired character set of the output value- Returns:
- the converted value
- Throws:
IOException- problem converting character set
-
convertCharset
public static String convertCharset(String input, String inputCharset, String outputCharset) throws IOException Converts the character encoding of the supplied input value.- Parameters:
input- input value to apply conversioninputCharset- character set of the input valueoutputCharset- desired character set of the output value- Returns:
- the converted value
- Throws:
IOException- problem converting character set
-
convertCharset
public static void convertCharset(@NonNull @NonNull InputStream input, @NonNull @NonNull Charset inputCharset, @NonNull @NonNull OutputStream output, @NonNull @NonNull Charset outputCharset) throws IOException Converts the character encoding of the supplied input.- Parameters:
input- input stream to apply conversioninputCharset- character set of the input streamoutput- where converted stream will be storedoutputCharset- desired character set of the output stream- Throws:
IOException- problem converting character set
-
convertCharset
public static void convertCharset(InputStream input, String inputCharset, OutputStream output, String outputCharset) throws IOException Converts the character encoding of the supplied input.- Parameters:
input- input stream to apply conversioninputCharset- character set of the input streamoutput- where converted stream will be storedoutputCharset- desired character set of the output stream- Throws:
IOException- problem converting character set
-
firstNonBlankOrUTF8
Returns the first non-blank character encoding, or returns UTF-8 if they are all blank.- Parameters:
charsets- character encodings to test- Returns:
- first non-blank, or UTF-8
-
firstNonBlankOrUTF8
Returns the first non-blank character encoding, or returns UTF-8 if they are all blank or in post-parse state. That is, UTF-8 is always returned if parsing has already occurred (since parsing converts content encoding to UTF-8).- Parameters:
parseState- document parsing statecharsets- character encodings to test- Returns:
- first non-blank, or UTF-8
-
firstNonNullOrUTF8
Returns the first non-blank character encoding, or returns UTF-8 if they are all blank.- Parameters:
charsets- character encodings to test- Returns:
- first non-blank, or UTF-8
-
firstNonNullOrUTF8
Returns the first non-blank character encoding, or returns UTF-8 if they are all blank or in post-parse state. That is, UTF-8 is always returned if parsing has already occurred (since parsing converts content encoding to UTF-8).- Parameters:
parseState- document parsing statecharsets- character encodings to test- Returns:
- first non-blank, or UTF-8
-