Standard library · Text

unicode

What Unicode knows about a character: category, script, writing direction, case, decomposition and composition.

import unicode

Unicode gives every character of every script in the world a number, called a code point: "ش" is 1588 and "A" is 65. For any code point, the unicode package says what kind of character it is: letter or digit, which script it belongs to, whether it is written right to left or left to right, and what its upper and lower case forms are.

Most of the time the str package is enough, and it uses this one underneath. This package is for when you are inspecting text character by character yourself, in a parser, an editor or a text cleaning tool. The data is generated from the official Unicode database, version 16.

To get the code points of a string, use str.CodePoints.

Two things to keep in mind:

•

A code point is not always what a reader sees as one letter. An accented letter can be two code points and an emoji family seven; str.Graphemes works at that level.

•

ToUpper, ToLower and ToTitle are the simple one to one mappings, so a character whose upper case is two letters keeps its form: ß stays ß. To compare text without case, use the full fold behind str.EqualFold rather than comparing upper cased copies.

Counting kinds of characters

A loop over str.CodePoints with the Is... functions sorts every character into a class. The classes come from the Unicode database, so they work for every script at once: the Persian digits count as digits, the Persian comma ، as punctuation and the kasra on سلامِ as a mark.

unicode-guide-stats.salam
import unicode
import str

func main:
    text := "Salam 2026! سلامِ ۱۴۰۵، café (ok)"
    cps := str.CodePoints(text)
    defer cps.Free()
    mut letters := 0
    mut digits := 0
    mut spaces := 0
    mut punct := 0
    mut marks := 0
    each cp in cps:
        if unicode.IsLetter(cp):
            letters++
        else unicode.IsDigit(cp):
            digits++
        else unicode.IsSpace(cp):
            spaces++
        else unicode.IsPunct(cp):
            punct++
        else unicode.IsMark(cp):
            marks++
        end
    end
    println "code points:", cps.Len()
    println "letters:", letters, "digits:", digits, "spaces:", spaces
    println "punctuation:", punct, "marks:", marks
end
Output
code points: 33
letters: 15 digits: 8 spaces: 5
punctuation: 4 marks: 1

The order of the tests matters only for characters that belong to two groups; letters, digits, spaces, punctuation and marks do not overlap. For finer detail, Category returns one of the 30 general categories, compared against the constants such as CatLo, and CategoryName its two letter code.

Guessing the direction of a line

When a page shows text written by users, each paragraph needs dir="rtl" or dir="ltr". The usual rule, the one browsers apply for dir="auto", is to take the direction of the first strong character. BidiClass gives that class: BcL for left to right, BcR for Hebrew and BcAL for Arabic script.

unicode-guide-direction.salam
import unicode
import str

func direction(text: str): str:
    cps := str.CodePoints(text)
    defer cps.Free()
    each cp in cps:
        bc := unicode.BidiClass(cp)
        if bc == unicode.BcL:
            ret "ltr"
        end
        if bc == unicode.BcR or bc == unicode.BcAL:
            ret "rtl"
        end
    end
    ret "neutral"
end

func main:
    each line in ["Hello", "سلام دنیا", "2026: سال نو", "(42) Answer", "!!! 123", "שלום"]:
        println direction(line), "|", line
    end
end
Output
ltr | Hello
rtl | سلام دنیا
rtl | 2026: سال نو
ltr | (42) Answer
neutral | !!! 123
rtl | שלום

Digits, spaces and punctuation are weak or neutral, so 2026: سال نو is right to left because the first letter is Persian. A line with no letters at all has no direction of its own; give it the direction of the surrounding page. For laying out a whole mixed paragraph, see bidi, which runs the complete algorithm.

Spotting mixed scripts in a user name

Some letters in different scripts look the same: the Cyrillic а is not the Latin a, yet pаypal with a Cyrillic letter looks exactly like the real name. A sign up form can refuse names that mix scripts. Script gives the script of each code point; skip ScriptCommon (digits, punctuation, _) and ScriptInherited (combining marks), which belong to every script.

unicode-guide-scripts.salam
import unicode
import str

func scripts_in(name: str): Vector<str>:
    mut found := Vector {} as Vector<str>
    cps := str.CodePoints(name)
    defer cps.Free()
    each cp in cps:
        sc := unicode.Script(cp)
        if sc == unicode.ScriptCommon or sc == unicode.ScriptInherited:
            continue
        end
        script := unicode.ScriptName(cp)
        mut seen := false
        each s in found:
            if s == script:
                seen = true
            end
        end
        if not seen:
            found.Push(script)
        end
    end
    ret found
end

func main:
    each name in ["paypal", "pаypal", "علی_2000", "Reza۱۳۷۰"]:
        s := scripts_in(name)
        verdict := s.Len() > 1 ? "mixed, check it" : "ok"
        println name, s, verdict
        s.Free()
    end
end
Output
paypal ["Latin"] ok
pаypal ["Latin", "Cyrillic"] mixed, check it
علی_2000 ["Arabic"] ok
Reza۱۳۷۰ ["Latin", "Arabic"] mixed, check it

The last name shows a trap: the Persian digits ۱۳۷۰ belong to the Arabic script, while the ASCII digits are Common. Whether a Latin name with Persian digits should pass is your decision; the function only reports the facts. The а escape writes the Cyrillic letter into the source so you can see it is there.

Removing accents and vowel marks

For a loose search, café should match cafe. Canonical decomposition splits é into e and a combining accent; drop every mark and keep the rest. DecompLen says how many parts a code point decomposes into, zero when it does not, and DecompAt returns each part.

unicode-guide-marks.salam
import unicode
import str

func strip_marks(text: str): str:
    mut b := str.NewBuilder()
    defer str.BufFree(b)
    cps := str.CodePoints(text)
    defer cps.Free()
    each cp in cps:
        n := unicode.DecompLen(cp)
        if n == 0:
            if not unicode.IsMark(cp):
                str.BufAppendCp(b, cp)
            end
            continue
        end
        repeat n in k:
            part := unicode.DecompAt(cp, k)
            if not unicode.IsMark(part):
                str.BufAppendCp(b, part)
            end
        end
    end
    ret str.BufStr(b)
end

func main:
    println strip_marks("café crème brûlée")
    println strip_marks("Ångström, naïve, São Paulo")
    println strip_marks("کِتابُ الْعَرَبِیَّة")
    println strip_marks("آموزشِ زبانِ برنامه‌نویسیِ سلام")
end
Output
cafe creme brulee
Angstrom, naive, Sao Paulo
کتاب العربیة
اموزش زبان برنامه‌نویسی سلام

The Arabic vowel marks go away, which is what a search usually wants. But look at the last line: آ decomposes into ا plus a madda, so the madda is removed too and آموزش becomes اموزش. That is wrong for Persian. For Persian and Arabic text use arabic, whose StripHarakat flag removes the vowel marks and leaves letters such as آ alone, and for whole strings use str.NFD and NFC rather than decomposing one level by hand.

Upper case in every script

str.Upper and str.Lower only change the ASCII letters, which is fast and enough for keywords and codes, but it leaves ü, Cyrillic and Greek alone. To change the case of any script, map each code point with ToUpper or ToLower and build the result again.

unicode-guide-upper.salam
import unicode
import str

func upper_all(text: str): str:
    mut b := str.NewBuilder()
    defer str.BufFree(b)
    cps := str.CodePoints(text)
    defer cps.Free()
    each cp in cps:
        str.BufAppendCp(b, unicode.ToUpper(cp))
    end
    ret str.BufStr(b)
end

func main:
    each city in ["Zürich", "São Paulo", "Москва", "Αθήνα", "Straße"]:
        println str.Upper(city), "|", upper_all(city)
    end
end
Output
ZüRICH | ZÜRICH
SãO PAULO | SÃO PAULO
Москва | МОСКВА
Αθήνα | ΑΘΉΝΑ
STRAßE | STRAßE

The left column is str.Upper, the right one the per code point mapping. The last line shows the limit of a simple mapping: ß has no single upper case letter, so it stays as it is. Persian and Arabic have no letter case, and these functions return their letters unchanged.

Constants and variables

ZWNJ

#
const ZWNJ: i32 = 8204

The code point of the zero width non-joiner (U+200C), which in Persian keeps two letters side by side without joining them, as in «می‌روم».

unicode-ZWNJ.salam
import unicode

func main:
    println unicode.ZWNJ, unicode.ZWJ, unicode.MaxCodePoint
    println "unicode", unicode.Version
end
Output
8204 8205 1114111
unicode 16.0.0

ZWJ

#
const ZWJ: i32 = 8205

The code point of the zero width joiner (U+200D), which joins two characters; composed emoji such as the family are built with it.

The example for this item is shown with the ones above: unicode-ZWNJ.salam

MaxCodePoint

#
const MaxCodePoint: i32 = 1114111

The largest code point Unicode allows, 0x10FFFF.

The example for this item is shown with the ones above: unicode-ZWNJ.salam

Hangul syllable constants

Hangul…#

The numbers needed to compose and decompose Korean (Hangul) syllables arithmetically. Each syllable is built from a leading consonant, a vowel and sometimes a trailing consonant, and its code point can be computed directly.

NameValue
HangulSBase
44032
HangulLBase
4352
HangulVBase
4449
HangulTBase
4519
HangulLCount
19
HangulVCount
21
HangulTCount
28
HangulNCount
588
HangulSCount
11172
unicode-Hangul.salam
import unicode

func main:
    lead := 18
    vowel := 0
    tail := 4
    syllable := unicode.HangulSBase + (lead * unicode.HangulVCount + vowel) * unicode.HangulTCount +
        tail
    println syllable
    println unicode.HangulNCount, unicode.HangulSCount
    println unicode.HangulLBase, unicode.HangulVBase, unicode.HangulTBase
    println unicode.HangulLCount
end
Output
54620
588 11172
4352 4449 4519
19

Version

#
const Version: str = "16.0.0"

The version of Unicode the data in this package was generated from.

The example for this item is shown with the ones above: unicode-ZWNJ.salam

MaxFoldLen

#
const MaxFoldLen: i32 = 3

The largest number of code points a full case fold of one character can produce. A buffer of this size is enough to fold any character.

unicode-ToUpper.salam
import unicode

func main:
    println unicode.ToUpper(945), unicode.ToLower(913), unicode.ToTitle(454), unicode.ToFold(913)
    println unicode.ToUpper(1588)
    c := 223
    println unicode.HasFullFold(c), unicode.FullFoldLen(c)
    repeat unicode.FullFoldLen(c) in i:
        print unicode.FullFoldAt(c, i), ""
    end
    println ""
    println unicode.MaxFoldLen
end
Output
913 945 453 945
1588
true 2
115 115 
3

General categories

Cat…#

Every Unicode character has a "general category". Category returns one of these numbers and CategoryName returns its two-letter short name, such as Lo. Categories whose first letter is the same are numbered consecutively.

NameValue
CatLu
0
CatLl
1
CatLt
2
CatLm
3
CatLo
4
CatMn
5
CatMc
6
CatMe
7
CatNd
8
CatNl
9
CatNo
10
CatPc
11
CatPd
12
CatPs
13
CatPe
14
CatPi
15
CatPf
16
CatPo
17
CatSm
18
CatSc
19
CatSk
20
CatSo
21
CatZs
22
CatZl
23
CatZp
24
CatCc
25
CatCf
26
CatCs
27
CatCo
28
CatCn
29
unicode-Category.salam
import unicode

func main:
    each c in [65, 1588, 1776, 1614, 8204, 12288, 888]:
        println c, unicode.CategoryName(c), unicode.Category(c), unicode.IsAssigned(c)
    end
    println unicode.Category(1588) == unicode.CatLo
end
Output
65 Lu 0 true
1588 Lo 4 true
1776 Nd 8 true
1614 Mn 5 true
8204 Cf 26 true
12288 Zs 22 true
888 Cn 29 false
true

Grapheme break classes

Gcb…#

The classes GraphemeBreak returns. The str package uses them to find where one "visible letter" ends and the next begins; a letter with its marks, or a composed emoji, is one cluster.

NameValue
GcbOther
0
GcbCR
1
GcbLF
2
GcbControl
3
GcbExtend
4
GcbZWJ
5
GcbRegionalIndicator
6
GcbPrepend
7
GcbSpacingMark
8
GcbL
9
GcbV
10
GcbT
11
GcbLV
12
GcbLVT
13
GcbExtendedPictographic
14
unicode-GraphemeBreak.salam
import unicode

func main:
    println unicode.GraphemeBreak(1614) == unicode.GcbExtend
    println unicode.GraphemeBreak(8205) == unicode.GcbZWJ
    println unicode.GraphemeBreak(128512) == unicode.GcbExtendedPictographic
    println unicode.GraphemeBreak(10), unicode.GraphemeBreak(65)
    println unicode.ConjunctBreak(2325) == unicode.IncbConsonant,
        unicode.ConjunctBreak(2381) == unicode.IncbLinker
end
Output
true
true
true
2 0
true true

Conjunct break classes

Incb…#

The classes ConjunctBreak returns. This rule keeps consonants joined by a virama in Indic scripts inside a single cluster.

NameValue
IncbNone
0
IncbConsonant
1
IncbExtend
2
IncbLinker
3

The example for this item is shown with the ones above: unicode-GraphemeBreak.salam

Bidirectional classes

Bc…#

The class BidiClass returns, which the bidirectional algorithm uses to decide where each character of mixed text appears. Arabic script letters are "Arabic", Latin letters are "left to right", and digits have classes of their own.

NameValue
BcL
0
BcR
1
BcAL
2
BcEN
3
BcES
4
BcET
5
BcAN
6
BcCS
7
BcNSM
8
BcBN
9
BcB
10
BcS
11
BcWS
12
BcON
13
BcLRE
14
BcRLE
15
BcLRO
16
BcRLO
17
BcPDF
18
BcLRI
19
BcRLI
20
BcFSI
21
BcPDI
22
unicode-BidiClass.salam
import unicode

func main:
    println unicode.BidiClass(65) == unicode.BcL
    println unicode.BidiClass(1588) == unicode.BcAL
    println unicode.BidiClass(1488) == unicode.BcR
    println unicode.BidiClass(1776) == unicode.BcEN, unicode.BidiClass(1632) == unicode.BcAN
    println unicode.PairedBracketType(40) == unicode.PbtOpen,
        unicode.PairedBracketType(41) == unicode.PbtClose
    println unicode.PairedBracket(40), unicode.PairedBracket(65)
end
Output
true
true
true
true true
true true
41 65

Paired bracket types

Pbt…#

The result of PairedBracketType: whether the character is an opening bracket, a closing one, or not a bracket at all.

NameValue
PbtNone
0
PbtOpen
1
PbtClose
2

The example for this item is shown with the ones above: unicode-BidiClass.salam

Script identifiers

Script…#

Every script Unicode knows has an identifier, and Script returns one of them. Persian and Arabic letters are both "Arabic script". "Common" characters such as digits and punctuation are used by several scripts, and "inherited" means the character takes the script of the character before it, as marks do.

NameValue
ScriptUnknown
0
ScriptCommon
1
ScriptLatin
2
ScriptGreek
3
ScriptCyrillic
4
ScriptArmenian
5
ScriptHebrew
6
ScriptArabic
7
ScriptSyriac
8
ScriptThaana
9
ScriptDevanagari
10
ScriptBengali
11
ScriptGurmukhi
12
ScriptGujarati
13
ScriptOriya
14
ScriptTamil
15
ScriptTelugu
16
ScriptKannada
17
ScriptMalayalam
18
ScriptSinhala
19
ScriptThai
20
ScriptLao
21
ScriptTibetan
22
ScriptMyanmar
23
ScriptGeorgian
24
ScriptHangul
25
ScriptEthiopic
26
ScriptCherokee
27
ScriptCanadianAboriginal
28
ScriptOgham
29
ScriptRunic
30
ScriptKhmer
31
ScriptMongolian
32
ScriptHiragana
33
ScriptKatakana
34
ScriptBopomofo
35
ScriptHan
36
ScriptYi
37
ScriptOldItalic
38
ScriptGothic
39
ScriptDeseret
40
ScriptInherited
41
ScriptTagalog
42
ScriptHanunoo
43
ScriptBuhid
44
ScriptTagbanwa
45
ScriptLimbu
46
ScriptTaiLe
47
ScriptLinearB
48
ScriptUgaritic
49
ScriptShavian
50
ScriptOsmanya
51
ScriptCypriot
52
ScriptBraille
53
ScriptBuginese
54
ScriptCoptic
55
ScriptNewTaiLue
56
ScriptGlagolitic
57
ScriptTifinagh
58
ScriptSylotiNagri
59
ScriptOldPersian
60
ScriptKharoshthi
61
ScriptBalinese
62
ScriptCuneiform
63
ScriptPhoenician
64
ScriptPhagsPa
65
ScriptNko
66
ScriptSundanese
67
ScriptLepcha
68
ScriptOlChiki
69
ScriptVai
70
ScriptSaurashtra
71
ScriptKayahLi
72
ScriptRejang
73
ScriptLycian
74
ScriptCarian
75
ScriptLydian
76
ScriptCham
77
ScriptTaiTham
78
ScriptTaiViet
79
ScriptAvestan
80
ScriptEgyptianHieroglyphs
81
ScriptSamaritan
82
ScriptLisu
83
ScriptBamum
84
ScriptJavanese
85
ScriptMeeteiMayek
86
ScriptImperialAramaic
87
ScriptOldSouthArabian
88
ScriptInscriptionalParthian
89
ScriptInscriptionalPahlavi
90
ScriptOldTurkic
91
ScriptKaithi
92
ScriptBatak
93
ScriptBrahmi
94
ScriptMandaic
95
ScriptChakma
96
ScriptMeroiticCursive
97
ScriptMeroiticHieroglyphs
98
ScriptMiao
99
ScriptSharada
100
ScriptSoraSompeng
101
ScriptTakri
102
ScriptCaucasianAlbanian
103
ScriptBassaVah
104
ScriptDuployan
105
ScriptElbasan
106
ScriptGrantha
107
ScriptPahawhHmong
108
ScriptKhojki
109
ScriptLinearA
110
ScriptMahajani
111
ScriptManichaean
112
ScriptMendeKikakui
113
ScriptModi
114
ScriptMro
115
ScriptOldNorthArabian
116
ScriptNabataean
117
ScriptPalmyrene
118
ScriptPauCinHau
119
ScriptOldPermic
120
ScriptPsalterPahlavi
121
ScriptSiddham
122
ScriptKhudawadi
123
ScriptTirhuta
124
ScriptWarangCiti
125
ScriptAhom
126
ScriptAnatolianHieroglyphs
127
ScriptHatran
128
ScriptMultani
129
ScriptOldHungarian
130
ScriptSignWriting
131
ScriptAdlam
132
ScriptBhaiksuki
133
ScriptMarchen
134
ScriptNewa
135
ScriptOsage
136
ScriptTangut
137
ScriptMasaramGondi
138
ScriptNushu
139
ScriptSoyombo
140
ScriptZanabazarSquare
141
ScriptDogra
142
ScriptGunjalaGondi
143
ScriptMakasar
144
ScriptMedefaidrin
145
ScriptHanifiRohingya
146
ScriptSogdian
147
ScriptOldSogdian
148
ScriptElymaic
149
ScriptNandinagari
150
ScriptNyiakengPuachueHmong
151
ScriptWancho
152
ScriptChorasmian
153
ScriptDivesAkuru
154
ScriptKhitanSmallScript
155
ScriptYezidi
156
ScriptCyproMinoan
157
ScriptOldUyghur
158
ScriptTangsa
159
ScriptToto
160
ScriptVithkuqi
161
ScriptKawi
162
ScriptNagMundari
163
ScriptGaray
164
ScriptGurungKhema
165
ScriptKiratRai
166
ScriptOlOnal
167
ScriptSunuwar
168
ScriptTodhri
169
ScriptTuluTigalari
170
unicode-Script.salam
import unicode

func main:
    each c in [65, 1588, 945, 20013, 12354, 1776, 1614]:
        println c, unicode.ScriptName(c)
    end
    println unicode.Script(1588) == unicode.ScriptArabic, unicode.Script(65) == unicode.ScriptLatin
    println unicode.Script(66464) == unicode.ScriptOldPersian, unicode.ScriptName(66464)
end
Output
65 Latin
1588 Arabic
945 Greek
20013 Han
12354 Hiragana
1776 Arabic
1614 Inherited
true true
true Old_Persian

Functions

Category

#
func Category(cp: int): int

Returns the number of the character's general category, one of the Cat constants above.

The example for this item is shown with the ones above: unicode-Category.salam

CategoryName

#
func CategoryName(cp: int): str

Returns the two-letter category name, such as Lo for a Persian letter and Nd for a digit.

The example for this item is shown with the ones above: unicode-Category.salam

IsAssigned

#
func IsAssigned(cp: int): bool

True when this code point has been assigned to a character in Unicode.

The example for this item is shown with the ones above: unicode-Category.salam

IsLetter

#
func IsLetter(cp: int): bool

True when the character is a letter, that is, in one of the L categories.

unicode-IsLetter.salam
import unicode

func main:
    println unicode.IsLetter(1588), unicode.IsAlphabetic(1614), unicode.IsLetter(1614)
    println unicode.IsUpper(915), unicode.IsLower(947), unicode.IsTitle(453)
    println unicode.IsMark(1614),
        unicode.IsDigit(1776),
        unicode.IsNumber(8544),
        unicode.IsDigit(8544)
    println unicode.IsAlnum(1776), unicode.IsPunct(1548), unicode.IsSymbol(65020)
    println unicode.IsSpace(12288),
        unicode.IsControl(10),
        unicode.IsFormat(8204),
        unicode.IsJoinControl(8204)
end
Output
true true false
true true true
true true true false
true true true
true true true true

IsAlphabetic

#
func IsAlphabetic(cp: int): bool

Like IsLetter, but wider: it also counts the marks that are part of reading a letter. Most of the time this is what "is it a letter?" means.

The example for this item is shown with the ones above: unicode-IsLetter.salam

IsUpper

#
func IsUpper(cp: int): bool

True when the character is an upper case letter.

The example for this item is shown with the ones above: unicode-IsLetter.salam

IsLower

#
func IsLower(cp: int): bool

True when the character is a lower case letter.

The example for this item is shown with the ones above: unicode-IsLetter.salam

IsTitle

#
func IsTitle(cp: int): bool

The few "title case" letters that are half upper and half lower case, such as "Dž".

The example for this item is shown with the ones above: unicode-IsLetter.salam

IsMark

#
func IsMark(cp: int): bool

True when the character is a combining mark, such as an accent or an Arabic vowel sign.

The example for this item is shown with the ones above: unicode-IsLetter.salam

IsDigit

#
func IsDigit(cp: int): bool

Decimal digits only, in any script; Persian digits count.

The example for this item is shown with the ones above: unicode-IsLetter.salam

IsNumber

#
func IsNumber(cp: int): bool

Any numeric character, Roman numerals and fractions included; wider than IsDigit.

The example for this item is shown with the ones above: unicode-IsLetter.salam

IsAlnum

#
func IsAlnum(cp: int): bool

A letter or a digit.

The example for this item is shown with the ones above: unicode-IsLetter.salam

IsPunct

#
func IsPunct(cp: int): bool

Punctuation, such as a comma in any script.

The example for this item is shown with the ones above: unicode-IsLetter.salam

IsSymbol

#
func IsSymbol(cp: int): bool

Symbols, such as currency signs and mathematical operators.

The example for this item is shown with the ones above: unicode-IsLetter.salam

IsSpace

#
func IsSpace(cp: int): bool

Whitespace characters by Unicode's official White_Space property. The zero width non-joiner is not whitespace.

The example for this item is shown with the ones above: unicode-IsLetter.salam

IsControl

#
func IsControl(cp: int): bool

Control characters.

The example for this item is shown with the ones above: unicode-IsLetter.salam

IsFormat

#
func IsFormat(cp: int): bool

Invisible formatting characters, such as the zero width non-joiner and the direction marks.

The example for this item is shown with the ones above: unicode-IsLetter.salam

IsJoinControl

#
func IsJoinControl(cp: int): bool

Only the zero width non-joiner and the zero width joiner, the two characters that control whether letters join.

The example for this item is shown with the ones above: unicode-IsLetter.salam

ToUpper

#
func ToUpper(cp: int): int

Returns the upper case form of a character, or the character itself when it has none.

The example for this item is shown with the ones above: unicode-ToUpper.salam

ToLower

#
func ToLower(cp: int): int

Returns the lower case form of a character.

The example for this item is shown with the ones above: unicode-ToUpper.salam

ToTitle

#
func ToTitle(cp: int): int

Returns the title case form of a character.

The example for this item is shown with the ones above: unicode-ToUpper.salam

ToFold

#
func ToFold(cp: int): int

Returns the simple case folded form of a character, the form used for case insensitive comparison.

The example for this item is shown with the ones above: unicode-ToUpper.salam

HasFullFold

#
func HasFullFold(cp: int): bool

True when the full case fold of the character is more than one code point, as "ß" folds to "ss".

The example for this item is shown with the ones above: unicode-ToUpper.salam

FullFoldLen

#
func FullFoldLen(cp: int): int

The number of code points in the character's full case fold.

The example for this item is shown with the ones above: unicode-ToUpper.salam

FullFoldAt

#
func FullFoldAt(cp: int, k: int): int

Code point number k of the character's full case fold.

The example for this item is shown with the ones above: unicode-ToUpper.salam

CombiningClass

#
func CombiningClass(cp: int): int

Returns the combining class of a mark. During normalisation, the marks following a letter are sorted by this number so that the order they were typed in does not matter. For ordinary characters it is zero.

unicode-Decomp.salam
import unicode

func main:
    alef_madda := 1570
    println unicode.DecompLen(alef_madda),
        unicode.DecompAt(alef_madda, 0),
        unicode.DecompAt(alef_madda, 1)
    println unicode.Compose(1575, 1619), unicode.Compose(1575, 65)
    println unicode.CombiningClass(1614), unicode.CombiningClass(1616), unicode.CombiningClass(1575)
    lam_alef := 65271
    println unicode.DecompLen(lam_alef), unicode.CompatDecompLen(lam_alef)
    println unicode.CompatDecompAt(lam_alef, 0), unicode.CompatDecompAt(lam_alef, 1)
end
Output
2 1575 1619
1570 -1
30 32 0
1 3
1604 1575

DecompLen

#
func DecompLen(cp: int): int

The number of code points in the character's canonical decomposition, or zero when it does not decompose.

The example for this item is shown with the ones above: unicode-Decomp.salam

DecompAt

#
func DecompAt(cp: int, k: int): int

Code point number k of the character's canonical decomposition.

The example for this item is shown with the ones above: unicode-Decomp.salam

CompatDecompLen

#
func CompatDecompLen(cp: int): int

The number of code points in the character's compatibility decomposition. Arabic presentation forms expand to ordinary letters here.

The example for this item is shown with the ones above: unicode-Decomp.salam

CompatDecompAt

#
func CompatDecompAt(cp: int, k: int): int

Code point number k of the compatibility decomposition.

The example for this item is shown with the ones above: unicode-Decomp.salam

Compose

#
func Compose(a: int, b: int): int

Combines two code points into one when they have a canonical composition, and returns minus one otherwise.

The example for this item is shown with the ones above: unicode-Decomp.salam

GraphemeBreak

#
func GraphemeBreak(cp: int): int

Returns the character's grapheme break class.

The example for this item is shown with the ones above: unicode-GraphemeBreak.salam

ConjunctBreak

#
func ConjunctBreak(cp: int): int

Returns the character's conjunct break class, used by Indic scripts.

The example for this item is shown with the ones above: unicode-GraphemeBreak.salam

BidiClass

#
func BidiClass(cp: int): int

Returns the character's bidirectional class.

The example for this item is shown with the ones above: unicode-BidiClass.salam

PairedBracketType

#
func PairedBracketType(cp: int): int

Says whether the character is an opening bracket, a closing one, or neither.

The example for this item is shown with the ones above: unicode-BidiClass.salam

PairedBracket

#
func PairedBracket(cp: int): int

Returns the partner of a bracket; the partner of "(" is ")". For a character that is not a bracket it returns the character itself.

The example for this item is shown with the ones above: unicode-BidiClass.salam

Script

#
func Script(cp: int): int

Returns the identifier of the character's script.

The example for this item is shown with the ones above: unicode-Script.salam

ScriptName

#
func ScriptName(cp: int): str

Returns the English name of the character's script, such as Arabic.

The example for this item is shown with the ones above: unicode-Script.salam