aboutsummaryrefslogtreecommitdiff
path: root/include/libunicode.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/libunicode.h')
-rw-r--r--include/libunicode.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/include/libunicode.h b/include/libunicode.h
new file mode 100644
index 0000000..e017ac5
--- /dev/null
+++ b/include/libunicode.h
@@ -0,0 +1,36 @@
+#pragma once
+
+typedef uint32 rune;
+
+/*
+ * We have to use the preprocessor to ensure
+ * we have unsigned constants. Unfortunate...
+ */
+
+#define UTFmax 4
+#define RuneSync 0x80u
+#define RuneSelf 0x80u
+#define RuneErr 0xFFFDu
+#define RuneMax 0x10FFFFu
+#define RuneMask 0x1FFFFFu
+
+/*
+ * UTF-8 functions.
+ */
+int utf8·len(char *s);
+int utf8·runelen(rune r);
+
+int utf8·fullrune(char *s, int n);
+char *utf8·findrune(char *s, long i);
+char *utf8·findrrune(char* s, long c);
+int utf8·bytetorune(rune *r, char *s);
+int utf8·runetobyte(char *s, rune *r);
+
+int utf8·isletter(rune r);
+int utf8·isdigit(rune r);
+int utf8·isspace(rune r);
+int utf8·istitle(rune r);
+
+rune utf8·toupper(rune r);
+rune utf8·tolower(rune r);
+rune utf8·totitle(rune r);