Introduction
CharsetUtil provides a toolkit wrapper for encoding operations and some common encoding constants.
Constants
Constants provide convenient references for encoding types, improving usability in the context of encoding.
String Forms
- ISO_8859_1
- UTF_8
- GBK
Charset Object Forms
- CHARSET_ISO_8859_1
- CHARSET_UTF_8
- CHARSET_GBK
Methods
Converting Encoding Strings to Charset Objects
The CharsetUtil.charset
method converts an encoding string to a Charset object.
Transforming Encodings
The CharsetUtil.convert
method is primarily used for converting between two different encodings. It addresses issues related to garbled text that may occur due to incorrect encoding recognition.
System Default Encoding
The CharsetUtil.defaultCharset
method is a wrapper for the Charset.defaultCharset()
method, which returns the system’s default encoding. The CharsetUtil.defaultCharsetName
method returns the default encoding as a string type.