1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

encoding.utf8: add is_number (#15931)

This commit is contained in:
ChAoS_UnItY
2022-10-01 16:01:51 +08:00
committed by GitHub
parent 3d2588f101
commit fe597b7172
3 changed files with 169 additions and 0 deletions

View File

@ -178,6 +178,14 @@ pub fn is_space(r rune) bool {
return is_excluding_latin(white_space_table, r)
}
// is_number returns true if the rune is unicode number or in unicode category N
pub fn is_number(r rune) bool {
if r <= max_latin_1 {
return props[u8(r)] & p_n != 0
}
return is_excluding_latin(number_table, r)
}
// is_uchar_punct return true if the input unicode is a western unicode punctuation
pub fn is_uchar_punct(uchar int) bool {
return find_punct_in_table(uchar, utf8.unicode_punct_western) != 0