about summary refs log tree commit diff stats
path: root/src/bindings/libunicode.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-12-19 23:36:16 +0100
committerbptato <nincsnevem662@gmail.com>2022-12-19 23:36:16 +0100
commit91d18d27e4eeebb5aa685b18b28130f3f1b4f513 (patch)
tree1bc2e19608b576582bb1edc3f0b18aed0eef477c /src/bindings/libunicode.nim
parentea9df035a294bf1cfa715c140d0d22aa018e262e (diff)
downloadchawan-91d18d27e4eeebb5aa685b18b28130f3f1b4f513.tar.gz
Add unicode normalization, etc
Diffstat (limited to 'src/bindings/libunicode.nim')
-rw-r--r--src/bindings/libunicode.nim23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/bindings/libunicode.nim b/src/bindings/libunicode.nim
new file mode 100644
index 00000000..d53fa060
--- /dev/null
+++ b/src/bindings/libunicode.nim
@@ -0,0 +1,23 @@
+type
+  DynBufReallocFunc = proc(opaque: pointer, p: pointer, size: csize_t): pointer {.cdecl.}
+
+  CharRange* = object
+    len*: cint # in points, always even
+    size*: cint
+    points*: ptr uint32 # points sorted by increasing value
+    mem_opaque*: pointer
+    realloc_func*: DynBufReallocFunc
+
+  UnicodeNormalizationEnum* {.size: sizeof(cint).} = enum
+    UNICODE_NFC, UNICODE_NFD, UNICODE_NKFC, UNICODE_NKFD
+
+proc cr_init*(cr: ptr CharRange, mem_opaque: pointer,
+              realloc_func: DynBufReallocFunc) {.importc.}
+
+proc cr_free*(cr: ptr CharRange) {.importc.}
+
+proc unicode_normalize*(pdst: ptr ptr uint32, src: ptr uint32, src_len: cint,
+                        n_type: UnicodeNormalizationEnum, opaque: pointer,
+                        realloc_func: DynBufReallocFunc): cint {.importc.}
+
+proc unicode_general_category*(cr: ptr CharRange, gc_name: cstring): cint {.importc.}