Scripts¶
Constructors¶
create¶
Returns¶
- Scripts val^
Public Functions¶
from_iso¶
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").
Parameters¶
- name: String box
Returns¶
of¶
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.
Parameters¶
- s: String box
Returns¶
- ScriptSet val
dominant¶
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.
Parameters¶
- s: String box
Returns¶
restrict_to¶
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.
Parameters¶
Returns¶
- Bool val
is_single_script¶
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.
Parameters¶
- s: String box
Returns¶
- Bool val
resolved_script_set¶
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.
Parameters¶
- s: String box
Returns¶
- ScriptSet val
eq¶
Parameters¶
- that: Scripts val
Returns¶
- Bool val
ne¶
Parameters¶
- that: Scripts val
Returns¶
- Bool val