Skip to content

Scripts

[Source]

primitive val Scripts

Constructors

create

[Source]

new val create()
: Scripts val^

Returns


Public Functions

from_iso

[Source]

Look up a Script by its long UCD name ("Latin", "Cyrillic", "Han", …). Returns None for unknown names. Case- and underscore-sensitive ("Anatolian_Hieroglyphs", not "Anatolian Hieroglyphs").

fun box from_iso(
  name: String box)
: (Script | None val)

Parameters

Returns


of

[Source]

The set of script(cp) values for every codepoint in s. ASCII digits, punctuation, etc. contribute ScriptCommon; combining marks contribute ScriptInherited. Use .resolved() on the result to drop those.

fun box of(
  s: String box)
: ScriptSet val

Parameters

Returns


dominant

[Source]

The script that occurs most often in s, ignoring ScriptCommon and ScriptInherited codepoints (digits, punctuation, combining marks). Ties are broken by first-seen. Returns ScriptCommon if s is empty or contains only Common/Inherited codepoints.

fun box dominant(
  s: String box)
: Script

Parameters

Returns


restrict_to

[Source]

True iff every codepoint in s either has a Common/Inherited script (which fits anywhere) or has at least one entry in its Script_Extensions that is also in allowed. This is the "identifier-allowlist" predicate from UAX #39 §5: pass it the scripts your application accepts (ScriptSet.create([ScriptLatin ]) for a Latin-only identifier policy) and it tells you whether s stays inside that allowlist.

fun box restrict_to(
  s: String box,
  allowed: ScriptSet val)
: Bool val

Parameters

Returns


is_single_script

[Source]

True iff there exists at least one script that every codepoint in s belongs to via Script_Extensions (UAX #39 §5.1). Empty strings and all-Common/all-Inherited strings are single-script.

Stronger than checking Scripts.of(s).resolved().size() == 1 — this honours Script_Extensions, so e.g. U+0640 ARABIC TATWEEL (extended to many Arabic-family scripts) doesn't force mixed-script just because its bare script is Arabic.

fun box is_single_script(
  s: String box)
: Bool val

Parameters

Returns


resolved_script_set

[Source]

UAX #39 §5.1 running intersection of Script_Extensions across all constraining codepoints (Common/Inherited are skipped). Empty result means either mixed-script or all-Common/Inherited; use is_single_script to disambiguate.

fun box resolved_script_set(
  s: String box)
: ScriptSet val

Parameters

Returns


eq

[Source]

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

Parameters

Returns


ne

[Source]

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

Parameters

Returns