moonucdUnicode for MoonBit

moonucd

moonbitstack/moonucd

What a character is and how it changes case.

fnbidi

pub fn bidi(Char) -> Bidi

The bidirectional class of ch, with the defaults the UCD assigns to unassigned code points.

fncategory

pub fn category(Char) -> Category

The category of ch; unassigned code points are Cn.

fnfold

pub fn fold(StringView) -> String

text case-folded with the full foldings, for caseless comparison.

fnhas

pub fn has(Char, Property) -> Bool

Whether ch has property.

fnlower

pub fn lower(StringView) -> String

text in lowercase, with the full mappings; a capital sigma at the end of a word becomes ς.

fnnumeric

pub fn numeric(Char) -> Numeric?

The numeric type of ch; None for characters without a numeric value.

fntitle

pub fn title(StringView) -> String

Every character of text mapped to its titlecase form. Words are not found here: callers decide which characters start one.

fnupper

pub fn upper(StringView) -> String

text in uppercase, with the full mappings: ß becomes SS.

fnversion

pub fn version() -> String

The version of the Unicode Character Database the tables come from.

enumBidi

Bidi_Class.

pub(all) enum Bidi {
  • L
  • R
  • AL
  • EN
  • ES
  • ET
  • AN
  • CS
  • NSM
  • BN
  • B
  • S
  • WS
  • ON
  • LRE
  • LRO
  • RLE
  • RLO
  • PDF
  • LRI
  • RLI
  • FSI
  • PDI

Implements Show.

enumCategory

General_Category.

pub(all) enum Category {
  • Lu
  • Ll
  • Lt
  • Lm
  • Lo
  • Mn
  • Mc
  • Me
  • Nd
  • Nl
  • No
  • Pc
  • Pd
  • Ps
  • Pe
  • Pi
  • Pf
  • Po
  • Sm
  • Sc
  • Sk
  • So
  • Zs
  • Zl
  • Zp
  • Cc
  • Cf
  • Cs
  • Co
  • Cn

Implements Show.

enumNumeric

Numeric_Type, for characters that have one.

pub(all) enum Numeric {
  • Decimal
  • Digit
  • Numeric

enumProperty

A binary property from PropList, DerivedCoreProperties and emoji-data.

pub(all) enum Property {
  • Alphabetic
  • Lowercase
  • Uppercase
  • Cased
  • CaseIgnorable
  • ChangesWhenLowercased
  • ChangesWhenUppercased
  • ChangesWhenTitlecased
  • ChangesWhenCasefolded
  • ChangesWhenCasemapped
  • IdStart
  • IdContinue
  • XidStart
  • XidContinue
  • DefaultIgnorableCodePoint
  • GraphemeExtend
  • GraphemeBase
  • Math
  • WhiteSpace
  • BidiControl
  • JoinControl
  • Dash
  • Hyphen
  • QuotationMark
  • TerminalPunctuation
  • HexDigit
  • AsciiHexDigit
  • Ideographic
  • Diacritic
  • Extender
  • NoncharacterCodePoint
  • IdsBinaryOperator
  • IdsTrinaryOperator
  • Radical
  • UnifiedIdeograph
  • Deprecated
  • SoftDotted
  • LogicalOrderException
  • SentenceTerminal
  • VariationSelector
  • PatternWhiteSpace
  • PatternSyntax
  • PrependedConcatenationMark
  • RegionalIndicator
  • Emoji
  • EmojiPresentation
  • EmojiModifier
  • EmojiModifierBase
  • EmojiComponent
  • ExtendedPictographic

age

moonbitstack/moonucd/age

The Unicode version that first assigned a code point.

fnage

pub fn age(Char) -> (Int32, Int32)?

When ch was first assigned, as the (major, minor) Unicode version — (1, 1) for the original repertoire, (17, 0) for the newest — or None for code points that are still unassigned.

fnversion

pub fn version() -> String

The version of the Unicode Character Database the tables come from.

block

moonbitstack/moonucd/block

The block a code point sits in, and the range of a block.

fnblock

pub fn block(Char) -> String?

The block ch belongs to, or None for the code points that sit in no block at all.

fnrange

pub fn range(StringView) -> (Char, Char)?

The first and last code point of the block called name, matched the loose way of UAX #44 (LM3): case, spaces, underscores, hyphens and a leading "is" are ignored. The short aliases of PropertyValueAliases.txt (ASCII, Greek, CJK) name their blocks too.

fnversion

pub fn version() -> String

The version of the Unicode Character Database the tables come from.

name

moonbitstack/moonucd/name

The name of a code point, and the code point a name names.

fnlookup

pub fn lookup(StringView) -> Char?

The code point named name, matched the loose way of UAX #44 (LM2): case, spaces, underscores and medial hyphens ignored, except the hyphen in U+1180's name. Formal names and every NameAliases alias resolve; a formal name wins over an alias spelled the same.

fnname

pub fn name(Char) -> String?

The name of ch, or None when the code point has none: unassigned code points, surrogates, private use and noncharacters. Hangul syllables and the ideograph-like scripts named PREFIX-XXXX (CJK, Tangut, Khitan, Nushu, Egyptian hieroglyphs) are spelled by the Standard's rules NR1 and NR2.

fnversion

pub fn version() -> String

The version of the Unicode Character Database the tables come from.

script

moonbitstack/moonucd/script

The script of a code point, and the scripts it is shared with.

fnextensions

pub fn extensions(Char) -> Array[Script]

The scripts ch can belong to: the ScriptExtensions.txt list when it has one, and [script(ch)] when it does not.

fnscript

pub fn script(Char) -> Script

The script of ch; unassigned and unknown code points are Unknown.

fnversion

pub fn version() -> String

The version of the Unicode Character Database the tables come from.

enumScript

Script, the writing system a character belongs to. The long name is what Show writes; Script::of reads both it and the four-letter code.

pub(all) enum Script {
  • Adlam
  • Ahom
  • AnatolianHieroglyphs
  • Arabic
  • Armenian
  • Avestan
  • Balinese
  • Bamum
  • BassaVah
  • Batak
  • Bengali
  • BeriaErfe
  • Bhaiksuki
  • Bopomofo
  • Brahmi
  • Braille
  • Buginese
  • Buhid
  • CanadianAboriginal
  • Carian
  • CaucasianAlbanian
  • Chakma
  • Cham
  • Cherokee
  • Chorasmian
  • Common
  • Coptic
  • Cuneiform
  • Cypriot
  • CyproMinoan
  • Cyrillic
  • Deseret
  • Devanagari
  • DivesAkuru
  • Dogra
  • Duployan
  • EgyptianHieroglyphs
  • Elbasan
  • Elymaic
  • Ethiopic
  • Garay
  • Georgian
  • Glagolitic
  • Gothic
  • Grantha
  • Greek
  • Gujarati
  • GunjalaGondi
  • Gurmukhi
  • GurungKhema
  • Han
  • Hangul
  • HanifiRohingya
  • Hanunoo
  • Hatran
  • Hebrew
  • Hiragana
  • ImperialAramaic
  • Inherited
  • InscriptionalPahlavi
  • InscriptionalParthian
  • Javanese
  • Kaithi
  • Kannada
  • Katakana
  • KatakanaOrHiragana
  • Kawi
  • KayahLi
  • Kharoshthi
  • KhitanSmallScript
  • Khmer
  • Khojki
  • Khudawadi
  • KiratRai
  • Lao
  • Latin
  • Lepcha
  • Limbu
  • LinearA
  • LinearB
  • Lisu
  • Lycian
  • Lydian
  • Mahajani
  • Makasar
  • Malayalam
  • Mandaic
  • Manichaean
  • Marchen
  • MasaramGondi
  • Medefaidrin
  • MeeteiMayek
  • MendeKikakui
  • MeroiticCursive
  • MeroiticHieroglyphs
  • Miao
  • Modi
  • Mongolian
  • Mro
  • Multani
  • Myanmar
  • Nabataean
  • NagMundari
  • Nandinagari
  • NewTaiLue
  • Newa
  • Nko
  • Nushu
  • NyiakengPuachueHmong
  • Ogham
  • OlChiki
  • OlOnal
  • OldHungarian
  • OldItalic
  • OldNorthArabian
  • OldPermic
  • OldPersian
  • OldSogdian
  • OldSouthArabian
  • OldTurkic
  • OldUyghur
  • Oriya
  • Osage
  • Osmanya
  • PahawhHmong
  • Palmyrene
  • PauCinHau
  • PhagsPa
  • Phoenician
  • PsalterPahlavi
  • Rejang
  • Runic
  • Samaritan
  • Saurashtra
  • Sharada
  • Shavian
  • Siddham
  • Sidetic
  • SignWriting
  • Sinhala
  • Sogdian
  • SoraSompeng
  • Soyombo
  • Sundanese
  • Sunuwar
  • SylotiNagri
  • Syriac
  • Tagalog
  • Tagbanwa
  • TaiLe
  • TaiTham
  • TaiViet
  • TaiYo
  • Takri
  • Tamil
  • Tangsa
  • Tangut
  • Telugu
  • Thaana
  • Thai
  • Tibetan
  • Tifinagh
  • Tirhuta
  • Todhri
  • TolongSiki
  • Toto
  • TuluTigalari
  • Ugaritic
  • Unknown
  • Vai
  • Vithkuqi
  • Wancho
  • WarangCiti
  • Yezidi
  • Yi
  • ZanabazarSquare

Implements Show.

pub fn Script::of(StringView) -> Self?

The script called name — a long name ("Latin", "Old Italic") or a four-letter code ("Latn", "Ital"), matched the loose way of UAX #44 (LM3): case, spaces, underscores, hyphens and a leading "is" are ignored.

normalize

moonbitstack/moonucd/normalize

The four normalization forms of UAX #15, combining classes and decompositions.

fncombining

pub fn combining(Char) -> Int32

The Canonical_Combining_Class of ch (0 when it has none).

fndecomposition

pub fn decomposition(Char) -> String

The first-level decomposition mapping of ch, as the UCD lists it: a space separated, upper-case, four-digit-hex sequence, or "" when ch has none.

fnis_normalized

pub fn is_normalized(Form, StringView) -> Bool

True when s is already in form (no change under normalize).

fnnormalize

pub fn normalize(Form, StringView) -> String

s in form — NFC, NFD, NFKC or NFKD — exactly as Unicode defines it: decompose recursively, put the sequence in canonical order, then compose the decomposed form when form is a composed one.

fnversion

pub fn version() -> String

The version of the Unicode Character Database the tables come from.

enumForm

A Unicode normalization form. NFC and NFKC are the composed forms; NFD and NFKD are the decomposed forms.

pub(all) enum Form {
  • NFC
  • NFD
  • NFKC
  • NFKD

Implements Show.

width

moonbitstack/moonucd/width

Terminal cells and East Asian Width.

fneast_asian_width

pub fn east_asian_width(Char) -> Eaw

The East Asian Width of ch (see Eaw).

fntext_width

pub fn text_width(StringView, ambiguous? : Int32) -> Int32

The number of terminal cells s occupies, or -1 when it holds a control character. A Zero Width Joiner hides the character after it, so an emoji sequence counts once, and a Variation Selector 16 (U+FE0F) after a character that takes an emoji presentation widens it by one cell. ambiguous is as for width.

fnversion

pub fn version() -> String

The version of the Unicode Character Database the width data comes from.

fnwidth

pub fn width(Char, ambiguous? : Int32) -> Int32

The number of terminal cells ch occupies: -1 for C0 and C1 control characters, 0 for NUL, combining marks and other zero-width code points, 2 for Wide and Fullwidth code points, and 1 otherwise. ambiguous is the width an East Asian Ambiguous character takes where it would otherwise take one cell; a CJK terminal draws them two wide.

enumEaw

The East Asian Width of ch, the UCD ea property: a code point is Wide (W) or Fullwidth (F) in two cells, Narrow (Na) or Halfwidth (H) in one, Ambiguous (A) depends on context, and Neutral (N) defaults to one. Unassigned code points and surrogates are Neutral.

pub(all) enum Eaw {
  • AAmbiguous
  • FFullwidth
  • HHalfwidth
  • NNeutral (the default)
  • NaNarrow
  • WWide

Implements Show.

segment

moonbitstack/moonucd/segment

Grapheme clusters, words and sentences, by UAX #29.

fngcb_property

pub fn gcb_property(Char) -> Gcb

The Grapheme_Cluster_Break property value of a character.

fngrapheme_at

pub fn grapheme_at(StringView, Int32) -> (Int32, Int32)

The grapheme cluster holding the UTF-16 offset at, as (start, end): where a cursor lands when it moves one user-perceived character.

fngrapheme_boundaries

pub fn grapheme_boundaries(Array[Int32]) -> Array[Bool]

Grapheme cluster boundaries: result[i] is true when a boundary falls between cps[i] and cps[i + 1], following UAX #29.

fngrapheme_clusters

pub fn grapheme_clusters(StringView) -> Array[String]

The extended grapheme clusters of a string.

fnsb_property

pub fn sb_property(Char) -> Sb

The Sentence_Break property value of a character.

fnsentence_boundaries

pub fn sentence_boundaries(Array[Int32]) -> Array[Bool]

Sentence boundaries, following UAX #29.

fnsentences

pub fn sentences(StringView) -> Array[String]

The sentences of a string.

fnversion

pub fn version() -> String

The version of the Unicode Character Database the tables come from.

fnwb_property

pub fn wb_property(Char) -> Wb

The Word_Break property value of a character.

fnword_at

pub fn word_at(StringView, Int32) -> (Int32, Int32)

The word, or run of spaces or punctuation, holding the UTF-16 offset at, as (start, end): what a double click selects.

fnword_boundaries

pub fn word_boundaries(Array[Int32]) -> Array[Bool]

Word boundaries, following UAX #29.

fnwords

pub fn words(StringView) -> Array[String]

The words of a string.

enumGcb

A Grapheme_Cluster_Break property value.

pub(all) enum Gcb {
  • Other
  • CR
  • LF
  • Control
  • Extend
  • ZWJ
  • RegionalIndicator
  • Prepend
  • SpacingMark
  • L
  • V
  • T
  • LV
  • LVT

Implements Show.

enumSb

A Sentence_Break property value.

pub(all) enum Sb {
  • Other
  • CR
  • LF
  • Sep
  • Extend
  • Format
  • Sp
  • Lower
  • Upper
  • OLetter
  • Numeric
  • ATerm
  • STerm
  • SContinue
  • Close

Implements Show.

enumWb

A Word_Break property value.

pub(all) enum Wb {
  • Other
  • CR
  • LF
  • Newline
  • Extend
  • ZWJ
  • Format
  • RegionalIndicator
  • Katakana
  • ALetter
  • HebrewLetter
  • MidLetter
  • MidNumLet
  • MidNum
  • Numeric
  • ExtendNumLet
  • WSegSpace
  • DoubleQuote
  • SingleQuote

Implements Show.

linebreak

moonbitstack/moonucd/linebreak

Line-break opportunities, by UAX #14.

fnbreaks

pub fn breaks(StringView) -> Array[(Int32, Bool)]

The break opportunities inside s, as the UTF-16 offset each line may end at and whether the line must end there (after a hard line break) or only may.

fnlb_property

pub fn lb_property(Char) -> Lb

The line-break class of a character.

fnlinebreak_boundaries

pub fn linebreak_boundaries(Array[Int32]) -> Array[Bool]

The line-break boundaries of a code point sequence: result[i] is true when a break opportunity falls between cps[i] and cps[i + 1], following UAX #14.

fnlinebreaks

pub fn linebreaks(StringView) -> Array[String]

The line-break opportunities of a string.

fnversion

pub fn version() -> String

The version of the Unicode Character Database the tables come from.

enumLb

A line-break class, after the LB1 resolution the algorithm applies.

pub(all) enum Lb {
  • XX
  • AI
  • AK
  • AL
  • AP
  • AS
  • B2
  • BA
  • BB
  • BK
  • CB
  • CJ
  • CL
  • CM
  • CP
  • CR
  • EB
  • EM
  • EX
  • GL
  • H2
  • H3
  • HH
  • HL
  • HY
  • ID
  • IN
  • IS
  • JL
  • JT
  • JV
  • LF
  • NL
  • NS
  • NU
  • OP
  • PO
  • PR
  • QU
  • RI
  • SA
  • SG
  • SP
  • SY
  • VF
  • VI
  • WJ
  • ZW
  • ZWJ

Implements Show.