blob: 1495101fc2b76eb954fb445fa19577be95cdb103 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#pragma warning(push)
#pragma warning(disable: 4245)
#include "utf8proc/utf8proc.h"
#pragma warning(pop)
// TODO(bill): Unicode support
b32 rune_is_letter(Rune r) {
if (r < 0x80 && gb_char_is_alpha(cast(char)r) || r == '_') {
return true;
}
switch (utf8proc_category(r)) {
case UTF8PROC_CATEGORY_LU:
case UTF8PROC_CATEGORY_LL:
case UTF8PROC_CATEGORY_LT:
case UTF8PROC_CATEGORY_LM:
case UTF8PROC_CATEGORY_LO:
return true;
}
return false;
}
b32 rune_is_digit(Rune r) {
if (r < 0x80 && gb_is_between(r, '0', '9'))
return true;
return utf8proc_category(r) == UTF8PROC_CATEGORY_ND;
}
b32 rune_is_whitespace(Rune r) {
switch (r) {
case ' ':
case '\t':
case '\n':
case '\r':
return true;
}
return false;
}
|