aboutsummaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorBert Münnich <ber.t@posteo.de>2017-12-07 14:57:02 +0100
committerBert Münnich <ber.t@posteo.de>2017-12-07 21:19:53 +0100
commit3c7d6f3528432a433cd368605e4dc6f0fecaa898 (patch)
treed05be3b28e7519ea5d00ea091efa18728992f87a /util.c
parent69b2d3cafdb580a5123747191c4fe92fccc47ced (diff)
downloadnsxiv-3c7d6f3528432a433cd368605e4dc6f0fecaa898.tar.zst
Replace utf8codepoint with Chris Wellons' utf8_decode
Code under a different license should be kept in a separate file. This implemention is a single header file with ~65 lines, so it better fits this requirement.
Diffstat (limited to 'util.c')
-rw-r--r--util.c28
1 files changed, 0 insertions, 28 deletions
diff --git a/util.c b/util.c
index 973bc80..8f41d78 100644
--- a/util.c
+++ b/util.c
@@ -205,31 +205,3 @@ int r_mkdir(char *path)
return 0;
}
-/* copied from sheredom's utf8.h (public domain) https://github.com/sheredom/utf8.h */
-
-void* utf8codepoint(const void* __restrict__ str, long* __restrict__ out_codepoint)
-{
- const char *s = (const char *)str;
-
- if (0xf0 == (0xf8 & s[0])) {
- // 4 byte utf8 codepoint
- *out_codepoint = ((0x07 & s[0]) << 18) | ((0x3f & s[1]) << 12) |
- ((0x3f & s[2]) << 6) | (0x3f & s[3]);
- s += 4;
- } else if (0xe0 == (0xf0 & s[0])) {
- // 3 byte utf8 codepoint
- *out_codepoint = ((0x0f & s[0]) << 12) | ((0x3f & s[1]) << 6) | (0x3f & s[2]);
- s += 3;
- } else if (0xc0 == (0xe0 & s[0])) {
- // 2 byte utf8 codepoint
- *out_codepoint = ((0x1f & s[0]) << 6) | (0x3f & s[1]);
- s += 2;
- } else {
- // 1 byte utf8 codepoint otherwise
- *out_codepoint = s[0];
- s += 1;
- }
-
- return (void *)s;
-}
-