gizlang:unicode
import * as Unicode from "gizlang:unicode";Functions
codePoints
function codePoints(text: string): Vec<i64>Generated from Unicode 17.0.0 UCD; do not edit tables. Unicode data: https://www.unicode.org/license.txt Unicode 17.0.0 algorithms. Tables are generated by generate.giz from the UCD. Lookup tables are bytes literals of fixed-width entries (Packed), read in place and searched in logarithmic time. Transformations allocate code points and one UTF-8 output; graphemes additionally copies each returned cluster. Canonical ordering is stable insertion ordering within a combining sequence (quadratic in a pathological descending sequence).
Effects: fail.
fromCodePoints
function fromCodePoints(cps: Vec<i64>): stringThe text made of these code points.
Effects: fail.
fromUtf8Lossy
function fromUtf8Lossy(data: bytes): stringThe text of UTF-8 bytes in which each ill-formed sequence is one U+FFFD, as Python's bytes.decode(errors="replace") and Hugging Face tokenizers decode it: a lead byte with fewer continuation bytes than it needs is one U+FFFD with those bytes; any other bad byte is one U+FFFD.
Effects: fail.
utf16Units
function utf16Units(text: string): Vec<u16>UTF-16 code units, including a surrogate pair for each supplementary scalar.
Effects: fail.
fromUtf16Units
function fromUtf16Units(units: Vec<u16>): Option<string>Decode UTF-16. An unpaired surrogate has no host UTF-8 string value.
Effects: fail.
toUpper
function toUpper(text: string): stringFull default case mapping; locale-specific Turkish/Lithuanian tailoring is absent.
Effects: fail.
toLower
function toLower(text: string): stringThe text with each letter in lower case.
Effects: fail.
fold
function fold(text: string): stringDefault full case folding (C/F entries, excluding Turkic T entries).
Effects: fail.
normalize
function normalize(text: string, form: string): string requires form === "NFC" || form === "NFD" || form === "NFKC" || form === "NFKD"TEXT in the Unicode normal form FORM: "NFC", "NFD", "NFKC" or "NFKD".
Effects: fail.
graphemes
function graphemes(text: string): Vec<string>The extended grapheme clusters of the text, each as text.
Effects: fail.
slug
function slug(text: string): stringA fragment id or address from text. It lowercases the NFC form, keeps each run of letters,
marks and digits (General_Category L, M, N), and writes each run of other scalars as one "-",
with no "-" at either end. It never fails; a text without letters or digits gives "".
Effects: fail.
isEmoji
function isEmoji(grapheme: string): boolTrue only for one RGI emoji from the pinned Unicode data.
Effects: fail.
propertyRanges
function propertyRanges(key: string): Option<Vec<i64>>The set of the property written as KEY in \p{KEY}: a binary property or a General_Category value by any of its
names (L, Letter, Alpha), or NAME=VALUE with NAME one of General_Category, gc, Script, sc, Script_Extensions, scx.
Names are matched exactly, as ECMAScript requires (no loose matching).
Effects: fail.
hasProperty
function hasProperty(key: string, cp: i64): boolWhether CP has the property written as KEY in \p{KEY} (as propertyRanges reads KEY); false for an unknown KEY.
Effects: fail.
combiningClass
function combiningClass(cp: i64): i64The Canonical_Combining_Class of CP (9 is a virama).
Effects: fail.
stringProperty
function stringProperty(name: string): Option<Vec<Vec<i64>>>The sequences of the property of strings NAME (v flag), each a Vec of code points. RGI_Emoji is the union of the other six (UTS #51 ED-27), composed here so it is not stored twice.
Effects: fail.
idStart
function idStart(cp: i64): boolID_Start, with the ECMAScript additions $ and _ excluded (the lexer adds them).
Effects: fail.
idContinue
function idContinue(cp: i64): boolWhether CP is a Unicode ID_Continue code point.
Effects: fail.
spaceSeparator
function spaceSeparator(cp: i64): boolSpace_Separator (Zs), for the white space of the lexer and of trim.
Effects: fail.
simpleFold
function simpleFold(cp: i64): i64scf: the simple case folding (CaseFolding C and S) of CP.
Effects: fail.
simpleUpper
function simpleUpper(cp: i64): i64The simple uppercase mapping (UnicodeData field 12) of CP.
Effects: fail.
foldOrbit
function foldOrbit(cp: i64): Vec<i64>Every code point with the same simple case folding as CP, CP included, sorted.
Effects: fail.
upperOrbit
function upperOrbit(cp: i64): Vec<i64>Every code point with the same simple uppercase mapping as CP, CP included, sorted.
Effects: fail.
simpleFoldPairs
function simpleFoldPairs(): Vec<i64>The simple folding and simple uppercase tables as flat (code point, mapping) pairs, sorted, without identities.
Effects: fail.
simpleUpperPairs
function simpleUpperPairs(): Vec<i64>The simple uppercase mapping as flat (code point, mapping) pairs, sorted, without identities.
Effects: fail.