Types
IRune = int
TRune = distinct IRune
- type that can hold any Unicode character
TRune16 = distinct int16
- 16 bit Unicode character
Procs
proc `<=%`(a, b: TRune): bool {.raises: [], tags: [].}
proc `<%`(a, b: TRune): bool {.raises: [], tags: [].}
proc `==`(a, b: TRune): bool {.raises: [], tags: [].}
proc runeLen(s: string): int {.rtl, extern: "nuc$1", raises: [], tags: [].}
- returns the number of Unicode characters of the string s.
proc runeLenAt(s: string; i: int): int {.raises: [], tags: [].}
- returns the number of bytes the rune starting at s[i] takes.
proc runeAt(s: string; i: int): TRune {.raises: [], tags: [].}
- returns the unicode character in s at byte index i
proc toUTF8(c: TRune): string {.rtl, extern: "nuc$1", raises: [], tags: [].}
- converts a rune into its UTF8 representation
proc `$`(rune: TRune): string {.raises: [], tags: [].}
proc `$`(runes: seq[TRune]): string {.raises: [], tags: [].}
- converts a sequence of runes to a string
proc toLower(c: TRune): TRune {.rtl, extern: "nuc$1", procvar, raises: [], tags: [].}
- Converts c into lower case. This works for any Unicode character. If possible, prefer toLower over toUpper.
proc toUpper(c: TRune): TRune {.rtl, extern: "nuc$1", procvar, raises: [], tags: [].}
- Converts c into upper case. This works for any Unicode character. If possible, prefer toLower over toUpper.
proc toTitle(c: TRune): TRune {.rtl, extern: "nuc$1", procvar, raises: [], tags: [].}
proc isLower(c: TRune): bool {.rtl, extern: "nuc$1", procvar, raises: [], tags: [].}
- returns true iff c is a lower case Unicode character If possible, prefer isLower over isUpper.
proc isUpper(c: TRune): bool {.rtl, extern: "nuc$1", procvar, raises: [], tags: [].}
- returns true iff c is a upper case Unicode character If possible, prefer isLower over isUpper.
proc isAlpha(c: TRune): bool {.rtl, extern: "nuc$1", procvar, raises: [], tags: [].}
- returns true iff c is an alpha Unicode character (i.e. a letter)
proc isTitle(c: TRune): bool {.rtl, extern: "nuc$1", procvar, raises: [], tags: [].}
proc isWhiteSpace(c: TRune): bool {.rtl, extern: "nuc$1", procvar, raises: [], tags: [].}
- returns true iff c is a Unicode whitespace character
proc cmpRunesIgnoreCase(a, b: string): int {.rtl, extern: "nuc$1", procvar, raises: [], tags: [].}
-
compares two UTF8 strings and ignores the case. Returns:
0 iff a == b
< 0 iff a < b
> 0 iff a > b
Iterators
iterator runes(s: string): TRune {.raises: [], tags: [].}
- iterates over any unicode character of the string s.
Templates
template fastRuneAt(s: string; i: int; result: expr; doInc = true)
- Returns the unicode character s[i] in result. If doInc == true i is incremented by the number of bytes that have been processed.