Skip to content

Codepoints

[Source]

primitive val Codepoints

Constructors

create

[Source]

new val create()
: Codepoints val^

Returns


Public Functions

from_u32

[Source]

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.

fun box from_u32(
  u: U32 val)
: (Codepoint val | InvalidScalar val)

Parameters

Returns


is_scalar

[Source]

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).

fun box is_scalar(
  u: U32 val)
: Bool val

Parameters

Returns


category

[Source]

The Unicode General Category of u. For codepoints outside the assigned Unicode space (or above U+10FFFF), returns Cn.

fun box category(
  u: U32 val)
: Category

Parameters

Returns


combining_class

[Source]

Canonical Combining Class. Most codepoints return 0; only combining marks have non-zero values.

fun box combining_class(
  u: U32 val)
: U8 val

Parameters

Returns


canonical_decomposition

[Source]

Canonical Decomposition_Mapping. None if absent (including Hangul syllables — algorithmic).

fun box canonical_decomposition(
  u: U32 val)
: (Array[U32 val] val | None val)

Parameters

Returns


compat_decomposition

[Source]

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.

fun box compat_decomposition(
  u: U32 val)
: (Array[U32 val] val | None val)

Parameters

Returns


simple_upper

[Source]

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).

fun box simple_upper(
  u: U32 val)
: U32 val

Parameters

Returns


simple_lower

[Source]

Simple_Lowercase_Mapping. Returns u itself when no mapping is defined.

fun box simple_lower(
  u: U32 val)
: U32 val

Parameters

Returns


simple_title

[Source]

Simple_Titlecase_Mapping. Returns u itself when no mapping is defined.

fun box simple_title(
  u: U32 val)
: U32 val

Parameters

Returns


full_upper

[Source]

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.

fun box full_upper(
  u: U32 val)
: (Array[U32 val] val | None val)

Parameters

Returns


full_lower

[Source]

Full Lowercase_Mapping from SpecialCasing.txt. None if no multi-cp expansion exists.

fun box full_lower(
  u: U32 val)
: (Array[U32 val] val | None val)

Parameters

Returns


full_title

[Source]

Full Titlecase_Mapping from SpecialCasing.txt. None if no multi-cp expansion exists.

fun box full_title(
  u: U32 val)
: (Array[U32 val] val | None val)

Parameters

Returns


simple_casefold

[Source]

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).

fun box simple_casefold(
  u: U32 val)
: U32 val

Parameters

Returns


full_casefold

[Source]

Default full case folding per UAX #44 — may expand to multiple codepoints. None for codepoints that fold to themselves.

fun box full_casefold(
  u: U32 val)
: (Array[U32 val] val | None val)

Parameters

Returns


grapheme_break

[Source]

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.

fun box grapheme_break(
  u: U32 val)
: GraphemeBreak

Parameters

Returns


script

[Source]

The Script property of u per Scripts.txt. Returns ScriptUnknown for codepoints with no assigned script.

fun box script(
  u: U32 val)
: Script

Parameters

Returns


script_extensions

[Source]

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)].

fun box script_extensions(
  u: U32 val)
: Array[Script] val

Parameters

Returns


east_asian_width

[Source]

The East_Asian_Width property of u per UAX #11. Returns EAWN (Neutral) for codepoints with no explicit assignment.

fun box east_asian_width(
  u: U32 val)
: EastAsianWidth

Parameters

Returns


has_binary_property

[Source]

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.

fun box has_binary_property(
  u: U32 val,
  p: BinaryProperty)
: Bool val

Parameters

Returns


name

[Source]

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).

fun box name(
  u: U32 val)
: (String val | None val)

Parameters

Returns


from_name

[Source]

The codepoint with the given Unicode name (case- and space-sensitive). Linear scan over ~30k entries — appropriate for interactive use, not for hot paths.

fun box from_name(
  name': String box)
: (U32 val | None val)

Parameters

Returns


is_full_composition_excluded

[Source]

True iff u has the Full_Composition_Exclusion property per DerivedNormalizationProps.txt. Used by NFC composition (M5).

fun box is_full_composition_excluded(
  u: U32 val)
: Bool val

Parameters

Returns


compose_canonical

[Source]

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).

fun box compose_canonical(
  lhs: U32 val,
  rhs: U32 val)
: (U32 val | None val)

Parameters

Returns


is_letter

[Source]

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.

fun box is_letter(
  u: U32 val)
: Bool val

Parameters

Returns


is_digit

[Source]

True iff u is a scalar AND its General Category is Decimal_Number (Nd). Non-scalar U32 values return false.

fun box is_digit(
  u: U32 val)
: Bool val

Parameters

Returns


is_whitespace

[Source]

True iff u is whitespace per a category-based approximation (see Codepoint.is_whitespace). Non-scalar U32 values return false.

fun box is_whitespace(
  u: U32 val)
: Bool val

Parameters

Returns


is_assigned

[Source]

True iff u is a scalar AND its General Category is anything other than Cn (Unassigned). Non-scalar U32 values return false.

fun box is_assigned(
  u: U32 val)
: Bool val

Parameters

Returns


count

[Source]

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.

fun box count(
  s: String box)
: (USize val | InvalidUtf8 val)

Parameters

Returns


is_all

[Source]

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.

fun box is_all(
  s: String box,
  p: {(U32): Bool} val)
: (Bool val | InvalidUtf8 val)

Parameters

  • s: String box
  • p: {(U32): Bool} val

Returns


eq

[Source]

fun box eq(
  that: Codepoints val)
: Bool val

Parameters

Returns


ne

[Source]

fun box ne(
  that: Codepoints val)
: Bool val

Parameters

Returns