-
A
runeis just a character in a string. -
Represents a Unicode code point.
-
Signed 32 bit integer;
distinct i32. -
The default value is
0, as it's just ani32. -
They just work like numbers in most cases; well they are numbers.
-
For example, to lower a rune you can
unicode.to_lower(r), but you can also justr - 32if you're only dealing with ASCII.-
Supposedly.
-
-
-
Rune values are comparable and ordered.
Untyped Runes / Rune Literals
-
Can be used to define a
rune,u8,u16.
foo := 'x'
// ^ ^
// rune untyped rune
foo: u8 = 'x'
// ^ ^
// u8 untyped rune
// This is valid for UTF-8 runes, for UTF-16 use u16.
foo: u16 = 'x'
// ^ ^
// u16 untyped rune
if str[i] == '\n'
// is using a rune literal as a `u8`
Other usages
skip_whitespace :: proc(t: ^Tokenizer) {
for {
switch t.ch {
case ' ', '\t', '\r', '\n':
advance_rune(t)
case:
return
}
}
}