KiteCharset

interface KiteCharset

A character set capable of encoding a Kotlin String to bytes and back.

Semantics match the host JVM:

  • encode replaces unmappable characters with the charset's substitution byte (?, 0x3F) for the table-driven charsets, exactly like String.getBytes(charset) does.

  • decode replaces undecodable byte sequences with U+FFFD, like new String(bytes, charset).

Properties

Link copied to clipboard
abstract val name: String

Canonical name, matching the Charset.name() ZXing compares against.

Functions

Link copied to clipboard
abstract fun canEncode(text: String): Boolean

True iff every character in text can be represented in this charset.

Link copied to clipboard
abstract fun decode(bytes: ByteArray, offset: Int = 0, length: Int = bytes.size - offset): String

Decodes length bytes of bytes starting at offset.

Link copied to clipboard
abstract fun encode(text: String): ByteArray

Encodes text to bytes. Unmappable chars become ? (0x3F).