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

Represents one Unicode scalar value.

A Char stores a valid Unicode code point in U+0000..U+10FFFF, excluding the UTF-16 surrogate range U+D800..U+DFFF. It therefore occupies 32 bits and can represent both Basic Multilingual Plane and supplementary characters without splitting them into surrogate pairs.

Char literals use apostrophes so their meaning cannot be confused with the backtick-delimited 16-bit CodeUnit literal syntax. U+0000 is a valid Char and remains valid inside a length-delimited String.

Example
letter as Char = 'K'
smile as Char = '😀'
escaped as Char = '\U0001F600'
assert smile == escaped
Properties
Modifier and Type Member Description
public readonly property isAscii
isAscii as Boolean
Indicates whether this Char belongs to ASCII.
public readonly property isBMP
isBMP as Boolean
Indicates whether this Char belongs to the Basic Multilingual Plane.
public readonly property utf16SequenceLength
utf16SequenceLength as UInt
Returns the number of UTF-16 code units required for this Char.
public readonly property utf8SequenceLength
utf8SequenceLength as UInt
Returns the number of UTF-8 bytes required for this Char.
Constructors
Modifier and Type Member Description
public native Char Builds the neutral Char value (U+0000).
public native Char
Char(value as Char)
Copies another Char.
public native Char
Char(value as CodeUnit)
Converts one UTF-16 code unit to a Char.
public native Char
Char(value as Int)
Creates a Char from a signed integer code point.
public native Char
Char(value as Long)
Creates a Char from a signed long code point.
public native Char
Char(value as UInt)
Creates a Char from an unsigned integer code point.
public native Char
Char(value as ULong)
Creates a Char from an unsigned long code point.
Methods
Modifier and Type Member Description
public native isAlnum
isAlnum() as Boolean
Determines whether this Char is alphabetic or a digit.
public native isAlpha
isAlpha() as Boolean
Determines whether this Char belongs to a Unicode alphabetic class.
public native isDigit
isDigit() as Boolean
Determines whether this Char belongs to a Unicode digit class.
public isSpace
isSpace() as Boolean
Tests the Unicode White_Space property, consistently with String.isSpace().
public native toInt
toInt() as Int
Returns this Unicode scalar as a signed integer.
public native toLower
toLower() as Char
Converts this Char to lowercase when a Unicode mapping exists.
public override toString
toString() as String
Returns this Unicode scalar as a one-character immutable String.
public native toUpper
toUpper() as Char
Converts this Char to uppercase when a Unicode mapping exists.