aboutsummaryrefslogtreecommitdiff
path: root/src/unicode.cpp
diff options
context:
space:
mode:
authorgingerBill <ginger.bill.22@gmail.com>2016-08-15 14:54:45 +0100
committergingerBill <ginger.bill.22@gmail.com>2016-08-15 15:02:45 +0100
commitdcbb2fcfbdbd3b35ddc44a4c542b7c6375e47214 (patch)
tree1670d1ea683c78be063649685c601a17c1dcb025 /src/unicode.cpp
parent3ed75b22a357292393618fc684b18a1d167f4eb7 (diff)
Full Unicode Support
Diffstat (limited to 'src/unicode.cpp')
-rw-r--r--src/unicode.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/unicode.cpp b/src/unicode.cpp
new file mode 100644
index 000000000..1495101fc
--- /dev/null
+++ b/src/unicode.cpp
@@ -0,0 +1,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;
+}