class Charset
source · line 10public class Charset private constructor(
/**
* The canonical encoding name after resolving accepted aliases.
*/
public val name: String) : Equals<Charset>, Hash, ToString
- Supertype
Equals<Charset> - Supertype
Hash - Supertype
ToString
A supported character encoding identified by its canonical name. Equality and hashing use that name. Whole-value conversions are convenient for bounded input; CharsetTranscoder preserves conversion state across buffers.
function encodeLossy
source · line 52public fun encodeLossy(text: String, options: CharsetEncodeOptions = CharsetEncodeOptions()): Array<Byte>
Encodes Unicode text while replacing characters that cannot be represented in this encoding.
parameter options
source · line 52options: CharsetEncodeOptions = CharsetEncodeOptions()
parameter text
source · line 52text: String
property name
source · line 14public val name: String
get: public read-only
The canonical encoding name after resolving accepted aliases.
function toString
source · line 26public override fun toString(): String
- Overrides
toString
Returns the canonical encoding name.
function encode
source · line 46public fun encode(text: String, options: CharsetEncodeOptions = CharsetEncodeOptions()): Array<Byte>
Encodes Unicode text. Characters that cannot be represented in this encoding throw CharsetException.
parameter options
source · line 46options: CharsetEncodeOptions = CharsetEncodeOptions()
parameter text
source · line 46text: String
function decode
source · line 32public fun decode(data: List<Byte>, options: CharsetDecodeOptions = CharsetDecodeOptions()): String
Decodes bytes using the selected BOM and byte-order policy. Malformed input throws CharsetException.
parameter data
source · line 32data: List<Byte>
parameter options
source · line 32options: CharsetDecodeOptions = CharsetDecodeOptions()
function equals
source · line 18public override operator fun equals(other: Charset): Boolean
- Overrides
equals
Compares canonical encoding names, so accepted aliases identify the same charset.
parameter other
source · line 18other: Charset
function decodeLossy
source · line 38public fun decodeLossy(data: List<Byte>, options: CharsetDecodeOptions = CharsetDecodeOptions()): String
Decodes bytes while replacing malformed input; BOM and byte-order options still apply.
parameter data
source · line 38data: List<Byte>
parameter options
source · line 38options: CharsetDecodeOptions = CharsetDecodeOptions()
function hash
source · line 22public override fun hash(): Long
- Overrides
hash
Hashes the canonical encoding name consistently with charset equality.