Under heavy development. This site describes the intended 1.0 language. Current features and performance vary. Development status
Sn50SnThe SnAPI programming language
Development · Evolving reference

char

One Unicode scalar, not one UTF-8 byte or displayed character.

Sn is under heavy development. This reference includes the intended 1.0 design; features may be incomplete in the current compiler. Read the status →

These examples describe the Development language contract. They are not a claim that every workflow is supported by the current public preview. Declaration excerpts belong inside a function unless a full module is shown.

Valid scalar range

A char is a Unicode scalar: U+0000 through U+D7FF, or U+E000 through U+10FFFF. U+D800 through U+DFFF are surrogate code points and are invalid char values; values above U+10FFFF are also invalid. A scalar can encode to 1–4 UTF-8 bytes. A displayed grapheme can contain several scalars.

let Ascii: char = 'A';
let Greek: char = 'λ';
let Emoji: char = '\u{1F642}';
let Last: char = '\u{10FFFF}';

Literals and comparisons

A single-quoted char literal must decode to exactly one scalar. Escapes include \n, \t, \0 and \u{H...}. Equality and ordering compare scalar values; ordering is not locale-aware collation. char does not provide integer arithmetic or general bitwise operations.

let Before: bool = 'A' < 'B';
let Equal: bool = 'λ' == '\u{3BB}';
// Rejected: let Invalid: char = '\u{D800}';
// Rejected: let Two: char = 'ab';

Text encoding

Use char for decoded scalar values and byte for encoded storage. Merely reinterpreting UTF-8 bytes does not decode them. String literals must be valid UTF-8 and do not normalize equivalent Unicode spellings.

let Scalar: char = 'λ';
let Encoded: str = "λ";
let Bytes: usize = Encoded.ByteLength; // 2, not 1
// A scalar and its encoded bytes are different domains.

See all primitive types and literals and user-defined suffixes.

Documentation snapshot: October 24, 2026 About versions ↗
Searching Development · language & standard library