← Standard library

char

struct char

Available without an import.

A 32-bit Unicode code-point value, defaulting to U+0000. Text encoding replaces surrogate or out-of-range values with U+FFFD. Classification and simple one-code-point casing use the bundled Unicode tables; use string casing for expansions such as sharp-s to SS.

api fn Main() : int32 {
    char accented = 'é';
    return accented.IsLetter() && accented.ByteWidth() == 2 && accented.ToUpper() == 'É' ? 1 : 0;
}

Char.wax:19

Members

constructorconstructor

public constructor ()

Creates U+0000.

Char.wax:24

GetHashCodemethod

public fn GetHashCode() : uint32

Hashes the stored code-point value.

Char.wax:30

ToStringmethod

public fn ToString() : string

Encodes this value as UTF-8, replacing invalid scalar values with U+FFFD.

Char.wax:42

ToStringBuffermethod

public fn ToStringBuffer(StringBuilder builder) : int32

Appends the UTF-8 encoding and returns the number of bytes appended. Invalid scalar values encode as U+FFFD.

Char.wax:51

Equalsmethod

public fn Equals(char other) : bool

Tests exact code-point equality.

Char.wax:59

CompareTomethod

public fn CompareTo(char other) : int32

Returns -1, 0, or 1 according to numeric code-point order, not locale collation.

Char.wax:63

ByteWidthmethod

public fn ByteWidth() : int32

Returns the UTF-8 encoded byte width, from 1 to 4. Invalid scalars return 3 for their U+FFFD replacement.

Char.wax:73

Categorymethod

public fn Category() : UnicodeCategory

Returns the Unicode General_Category.

Char.wax:87

IsLettermethod

public fn IsLetter() : bool

Tests for any of the five Unicode letter categories.

Char.wax:91

IsDigitmethod

public fn IsDigit() : bool

Tests for Unicode decimal digits, including non-ASCII scripts.

Char.wax:95

IsWhitespacemethod

public fn IsWhitespace() : bool

Tests the Unicode White_Space binary property.

Char.wax:99

IsUppermethod

public fn IsUpper() : bool

Tests the UppercaseLetter category.

Char.wax:103

IsLowermethod

public fn IsLower() : bool

Tests the LowercaseLetter category.

Char.wax:107

IsPunctuationmethod

public fn IsPunctuation() : bool

Tests for any Unicode punctuation category.

Char.wax:111

IsLetterOrDigitmethod

public fn IsLetterOrDigit() : bool

Tests for a Unicode letter or decimal digit.

Char.wax:115

IsNumbermethod

public fn IsNumber() : bool

Tests for decimal digits, letter numbers, or other Unicode numbers.

Char.wax:119

ToUppermethod

public fn ToUpper() : char

Applies the simple one-code-point uppercase mapping. Does not expand to multiple characters.

Char.wax:126

ToLowermethod

public fn ToLower() : char

Applies the simple one-code-point lowercase mapping. Does not apply contextual or locale-specific string casing.

Char.wax:131

ToUpperCharCountmethod

public fn ToUpperCharCount() : int32

Returns one, since character uppercase mapping never expands.

Char.wax:135

ToLowerCharCountmethod

public fn ToLowerCharCount() : int32

Returns one, since character lowercase mapping never expands.

Char.wax:139

ScriptOfmethod

public fn ScriptOf() : UnicodeScript

Returns the Unicode Script property, including Common and Inherited where applicable.

Char.wax:148

HasBinaryPropertymethod

public fn HasBinaryProperty(UnicodeBinaryProperty prop) : bool

Tests membership in the supplied Unicode binary property.

Char.wax:152