v/vlib/builtin/utf8_test.v

15 lines
277 B
V
Raw Normal View History

fn test_utf8_char_len() {
2020-03-26 17:14:24 +01:00
assert utf8_char_len(`a`) == 1
println(utf8_char_len(`a`))
s := 'п'
assert utf8_char_len(s[0]) == 2
}
2021-01-01 10:06:09 +01:00
fn test_utf8_wide_char() {
2021-01-02 13:55:21 +01:00
r := ``
2021-01-01 10:06:09 +01:00
val := r.str().str
unsafe {
2021-01-02 13:55:21 +01:00
assert '${val[0]:x}${val[1]:x}${val[2]:x}${val[3]:x}' == 'e29c940'
2021-01-01 10:06:09 +01:00
}
}