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

  1. ISO_8859_1
  2. UTF_8
  3. GBK

Charset Object Forms

  1. CHARSET_ISO_8859_1
  2. CHARSET_UTF_8
  3. 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.