CodeUnit
classin packageklyn
public class CodeUnit implements ValueType:
CodeUnit
All Implemented Interfaces: ValueType

Represents one 16-bit UTF-16 code unit.

Characters in the Basic Multilingual Plane use one CodeUnit. Supplementary Unicode characters use a surrogate pair and therefore occupy two CodeUnit values when represented as UTF-16. A \uXXXX escape denotes one code unit; a \UXXXXXXXX escape is accepted as a CodeUnit only when its value remains in the Basic Multilingual Plane. Use a String literal or an explicit surrogate pair for a supplementary character.

letter as CodeUnit = `a`
assert letter.toUpper() == `A`

high as CodeUnit = `\uD83D`
low as CodeUnit = `\uDE00`
assert String.fromCodePoint(0x1F600) == "\U0001F600"
Constructors
Modifier and Type Member Description
public native CodeUnit Builds the neutral CodeUnit value (\u0000).
public native CodeUnit
CodeUnit(value as Char)
Narrows a Basic Multilingual Plane Char to one UTF-16 code unit.
public native CodeUnit Creates a CodeUnit from another CodeUnit value.
public native CodeUnit
CodeUnit(value: Int)
Creates a CodeUnit from a signed UTF-16 code-unit value.
public native CodeUnit
CodeUnit(value: Long)
Creates a CodeUnit from a signed UTF-16 code-unit value.
public native CodeUnit
CodeUnit(value: UInt)
Creates a CodeUnit from an unsigned UTF-16 code-unit value.
public native CodeUnit
CodeUnit(value: ULong)
Creates a CodeUnit from an unsigned UTF-16 code-unit value.
Methods
Modifier and Type Member Description
public native isAlnum
isAlnum() as Boolean
Determines whether a character is alphabetic or a digit.
public native isAlpha
isAlpha() as Boolean
Determines whether a character belongs to a Unicode alphabetic class.
public native isDigit
isDigit() as Boolean
Determines whether a character is a Unicode digit.
public native toInt
toInt() as Int
Returns the unsigned numeric value of this UTF-16 code unit.
public native toLower
toLower() as CodeUnit
Converts a character to lowercase when a lowercase mapping exists.
public native toUpper
toUpper() as CodeUnit
Converts a character to uppercase when an uppercase mapping exists.