summaryrefslogtreecommitdiff
path: root/include/unicode.h
diff options
context:
space:
mode:
authoremersion <[email protected]>2018-04-04 20:16:35 -0400
committerGitHub <[email protected]>2018-04-04 20:16:35 -0400
commitf2153f3f28c8aa2e6738610abf09b2e2396d891a (patch)
tree4702abb406a59fb8588cbd2019741e99d40bcbfe /include/unicode.h
parent3852a710ca62a76f4fd9c6ff9d28e7e5d5fcf78d (diff)
parent5d444b34f6af17894e2808c9d25948db625dabde (diff)
Merge pull request #1705 from swaywm/swaylock-layers
Port swaylock to layer shell
Diffstat (limited to 'include/unicode.h')
-rw-r--r--include/unicode.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/include/unicode.h b/include/unicode.h
new file mode 100644
index 00000000..e2ee9588
--- /dev/null
+++ b/include/unicode.h
@@ -0,0 +1,33 @@
+#ifndef _SWAY_UNICODE_H
+#define _SWAY_UNICODE_H
+#include <stddef.h>
+#include <stdint.h>
+
+// Technically UTF-8 supports up to 6 byte codepoints, but Unicode itself
+// doesn't really bother with more than 4.
+#define UTF8_MAX_SIZE 4
+
+#define UTF8_INVALID 0x80
+
+/**
+ * Grabs the next UTF-8 character and advances the string pointer
+ */
+uint32_t utf8_decode(const char **str);
+
+/**
+ * Encodes a character as UTF-8 and returns the length of that character.
+ */
+size_t utf8_encode(char *str, uint32_t ch);
+
+/**
+ * Returns the size of the next UTF-8 character
+ */
+int utf8_size(const char *str);
+
+/**
+ * Returns the size of a UTF-8 character
+ */
+size_t utf8_chsize(uint32_t ch);
+
+#endif
+