The Unicode Character Database for MoonBit.
moon add moonbitstack/moonucd@moonucd.category('Dž') // Lt
@moonucd.upper("straße") // "STRASSE"
@moonucd.fold("Straße") == @moonucd.fold("STRASSE") // true
@name.name('中') // Some("CJK UNIFIED IDEOGRAPH-4E2D")
@width.text_width("Hello 世界") // 10
@segment.grapheme_clusters("🇨🇳e\u{301}!") // ["🇨🇳", "é", "!"]
@linebreak.linebreaks("The quick 中文 fox") // ["The ", "quick ", "中", "文 ", "fox"]@moonucd.has('_', XidContinue) // true
@moonucd.lower("ΣΟΦΟΣ ΣΟΦΟΣ") // "σοφος σοφος"
@age.age('€') // Some((2, 1))
@block.range("Greek") // Some(('\u{370}', '\u{3FF}'))
@name.lookup("copyright sign") // Some('©')
@script.extensions('ー') // [Hiragana, Katakana]
@normalize.normalize(NFKC, "hello") // "hello"
@normalize.decomposition('½') // "<fraction> 0031 2044 0032"
@width.width('α', ambiguous=2) // 2
@segment.word_at("hello, world", 9) // (7, 12)
@linebreak.breaks("one two\nthree") // [(4, false), (8, true)]| Example | Shows |
|---|---|
| 01-tour | category, numeric type, binary properties, case |
| 02-scripts | script, extensions, Script::of |
| 03-width | width, east_asian_width, text_width |
| 04-normalize | normalize, is_normalized, decomposition |
| 05-segment | grapheme_clusters, words, sentences |
| 06-linebreak | linebreaks, lb_property |
| 07-terminal | wrapping and truncating text by terminal cells |
moon run src/examples/07-terminalpub(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
} derive(Eq)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
} derive(Eq)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
} derive(Eq)fn fold(text : StringView) -> Stringfn lower(text : StringView) -> Stringfn title(text : StringView) -> Stringfn upper(text : StringView) -> Stringfn version() -> String