Codepoints¶
Constructors¶
create¶
Returns¶
- Codepoints val^
Public Functions¶
from_u32¶
Wrap a U32 as a Codepoint val after validating it as a Unicode
scalar value (0x0000..0xD7FF or 0xE000..0x10FFFF). Returns
InvalidScalar for surrogates or values above U+10FFFF.
Parameters¶
- u: U32 val
Returns¶
- (Codepoint val | InvalidScalar val)
is_scalar¶
True iff u is a Unicode scalar value — the values that can appear
in well-formed UTF-8. Equivalent to (u < 0xD800) or
(0xE000 <= u <= 0x10FFFF).
Parameters¶
- u: U32 val
Returns¶
- Bool val
category¶
The Unicode General Category of u. For codepoints outside the
assigned Unicode space (or above U+10FFFF), returns Cn.
Parameters¶
- u: U32 val
Returns¶
combining_class¶
Canonical Combining Class. Most codepoints return 0; only combining marks have non-zero values.
Parameters¶
- u: U32 val
Returns¶
- U8 val
canonical_decomposition¶
Canonical Decomposition_Mapping. None if absent (including
Hangul syllables — algorithmic).
Parameters¶
- u: U32 val
Returns¶
compat_decomposition¶
Compatibility Decomposition_Mapping per UAX #44. None if
absent. Compat decomps are 1..18 codepoints long. Used by NFKD
(M5). Codepoints with a canonical decomp do NOT also have a
compat decomp — call canonical_decomposition first.
Parameters¶
- u: U32 val
Returns¶
simple_upper¶
Simple_Uppercase_Mapping. Returns u itself when no mapping is
defined. Single-codepoint result only — see Case (M6) for the
full mapping that can expand to multiple codepoints (e.g.,
German ß → SS).
Parameters¶
- u: U32 val
Returns¶
- U32 val
simple_lower¶
Simple_Lowercase_Mapping. Returns u itself when no mapping
is defined.
Parameters¶
- u: U32 val
Returns¶
- U32 val
simple_title¶
Simple_Titlecase_Mapping. Returns u itself when no mapping
is defined.
Parameters¶
- u: U32 val
Returns¶
- U32 val
full_upper¶
Full Uppercase_Mapping for u from SpecialCasing.txt — may
expand to multiple codepoints (e.g., ß → SS = [0x53, 0x53]).
Returns None if no expansion exists; callers should fall back
to simple_upper(u) in that case.
Parameters¶
- u: U32 val
Returns¶
full_lower¶
Full Lowercase_Mapping from SpecialCasing.txt. None if no
multi-cp expansion exists.
Parameters¶
- u: U32 val
Returns¶
full_title¶
Full Titlecase_Mapping from SpecialCasing.txt. None if no
multi-cp expansion exists.
Parameters¶
- u: U32 val
Returns¶
simple_casefold¶
Simple case folding per UAX #44 — maps u to its
case-fold-equivalent single codepoint. Returns u itself when
no mapping is defined. Use full_casefold to handle ß → ss,
which simple folding leaves alone (length-preserving).
Parameters¶
- u: U32 val
Returns¶
- U32 val
full_casefold¶
Default full case folding per UAX #44 — may expand to multiple
codepoints. None for codepoints that fold to themselves.
Parameters¶
- u: U32 val
Returns¶
grapheme_break¶
UAX #29 Grapheme_Cluster_Break property of u, including
Extended_Pictographic for emoji per UTS #51. Used by the
grapheme-break state machine to decide cluster boundaries.
Codepoints with no assigned value default to GBOther.
Parameters¶
- u: U32 val
Returns¶
script¶
The Script property of u per Scripts.txt. Returns
ScriptUnknown for codepoints with no assigned script.
Parameters¶
- u: U32 val
Returns¶
script_extensions¶
The Script_Extensions property of u per UAX #24. Returns the
set of scripts that use u, in the order they appear in
ScriptExtensions.txt. For codepoints not listed there (the vast
majority), the result is [script(u)].
Parameters¶
- u: U32 val
Returns¶
east_asian_width¶
The East_Asian_Width property of u per UAX #11. Returns EAWN
(Neutral) for codepoints with no explicit assignment.
Parameters¶
- u: U32 val
Returns¶
has_binary_property¶
True iff u has the binary property p per PropList.txt,
DerivedCoreProperties.txt, or emoji-data.txt. Use
BinaryProperties.from_iso(name) to look up a BinaryProperty
by its UCD name.
Parameters¶
- u: U32 val
- p: BinaryProperty
Returns¶
- Bool val
name¶
The canonical Unicode name of u per UnicodeData.txt column 1,
e.g. "LATIN CAPITAL LETTER A". Returns None for codepoints
without a real name (controls, surrogates, private use, ranges
like CJK Ideographs with algorithmic names).
Parameters¶
- u: U32 val
Returns¶
from_name¶
The codepoint with the given Unicode name (case- and space-sensitive). Linear scan over ~30k entries — appropriate for interactive use, not for hot paths.
Parameters¶
- name': String box
Returns¶
is_full_composition_excluded¶
True iff u has the Full_Composition_Exclusion property per
DerivedNormalizationProps.txt. Used by NFC composition (M5).
Parameters¶
- u: U32 val
Returns¶
- Bool val
compose_canonical¶
Canonical composition: (lhs, rhs) → result for primary
composites (entries whose target is not in the
Full_Composition_Exclusion set). Returns None if no composition
exists. Used by NFC (M5).
Parameters¶
Returns¶
is_letter¶
True iff u is a scalar AND its General Category is one of the
Letter categories: Lu, Ll, Lt, Lm, Lo. Non-scalar U32 values
return false.
Parameters¶
- u: U32 val
Returns¶
- Bool val
is_digit¶
True iff u is a scalar AND its General Category is Decimal_Number
(Nd). Non-scalar U32 values return false.
Parameters¶
- u: U32 val
Returns¶
- Bool val
is_whitespace¶
True iff u is whitespace per a category-based approximation
(see Codepoint.is_whitespace). Non-scalar U32 values return
false.
Parameters¶
- u: U32 val
Returns¶
- Bool val
is_assigned¶
True iff u is a scalar AND its General Category is anything other
than Cn (Unassigned). Non-scalar U32 values return false.
Parameters¶
- u: U32 val
Returns¶
- Bool val
count¶
Number of Unicode codepoints in s. Returns InvalidUtf8 if s
isn't well-formed UTF-8 — error carries the byte offset of the
first ill-formed sequence.
Parameters¶
- s: String box
Returns¶
- (USize val | InvalidUtf8 val)
is_all¶
True iff every codepoint in s satisfies the predicate p. An
empty string returns true (vacuously). Returns InvalidUtf8 if
s isn't well-formed UTF-8.
Parameters¶
- s: String box
- p: {(U32): Bool} val
Returns¶
- (Bool val | InvalidUtf8 val)
eq¶
Parameters¶
- that: Codepoints val
Returns¶
- Bool val
ne¶
Parameters¶
- that: Codepoints val
Returns¶
- Bool val