Class StandardEncodingTranslator
- java.lang.Object
-
- org.htmlunit.cyberneko.xerces.util.StandardEncodingTranslator
-
- All Implemented Interfaces:
EncodingTranslator
public final class StandardEncodingTranslator extends java.lang.Object implements EncodingTranslator
EncodingTranslator based on https://encoding.spec.whatwg.org/#names-and-labels
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.Map<java.lang.String,java.lang.String>
ENCODING_FROM_LABEL
Encoding names and labels Made public to let other also use this (like HtmlUnit TextDecoder).static java.util.Map<java.lang.String,java.lang.String>
ENCODING_TO_IANA_ENCODING
Differences from iana naming Made public to let other also use this (like HtmlUnit TextDecoder).static java.util.Map<java.lang.String,java.lang.String>
IANA_TO_JAVA_ENCODINGS
static StandardEncodingTranslator
INSTANCE
Singleton.static java.lang.String
REPLACEMENT
https://encoding.spec.whatwg.org/#replacement For the moment we are using this constant in theHTMLScanner
to support this encoding.
-
Constructor Summary
Constructors Modifier Constructor Description private
StandardEncodingTranslator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
encodingNameFromLabel(java.lang.String charsetLabel)
-
-
-
Field Detail
-
INSTANCE
public static final StandardEncodingTranslator INSTANCE
Singleton.
-
REPLACEMENT
public static final java.lang.String REPLACEMENT
https://encoding.spec.whatwg.org/#replacement For the moment we are using this constant in theHTMLScanner
to support this encoding. Another option might be to install a proper charset impl in the jvm (like https://github.com/lovasoa/replacement-charset-java) but this might introduce some behavior changes for the whole vm and therefore we handle it here.- See Also:
- Constant Field Values
-
ENCODING_FROM_LABEL
public static final java.util.Map<java.lang.String,java.lang.String> ENCODING_FROM_LABEL
Encoding names and labels Made public to let other also use this (like HtmlUnit TextDecoder).
-
ENCODING_TO_IANA_ENCODING
public static final java.util.Map<java.lang.String,java.lang.String> ENCODING_TO_IANA_ENCODING
Differences from iana naming Made public to let other also use this (like HtmlUnit TextDecoder).
-
IANA_TO_JAVA_ENCODINGS
public static final java.util.Map<java.lang.String,java.lang.String> IANA_TO_JAVA_ENCODINGS
-
-
Method Detail
-
encodingNameFromLabel
public java.lang.String encodingNameFromLabel(java.lang.String charsetLabel)
- Specified by:
encodingNameFromLabel
in interfaceEncodingTranslator
- Returns:
- the Java encoding name for the specified HTTP encoding name, or
null
if the name is unknown. The returned encoding name may or may not be supported by the running JVM. UseCharset.isSupported(String)
to check availability. Moreover, either of the special definitionsREPLACEMENT
or#USER_DEFINED
may be returned depending on input.
-
-