diff options
author | Phil Jones <philj56@gmail.com> | 2022-12-20 23:53:20 +0000 |
---|---|---|
committer | Phil Jones <philj56@gmail.com> | 2022-12-21 00:15:16 +0000 |
commit | 6c47cf7892d0f212b04e7b798e53c120f51022d7 (patch) | |
tree | c44b910e059d5bdcf991b2239de8d29cb007bed6 /src/unicode.c | |
parent | 108550fcf8d3ed8664c0e05defceaf20b4d2b49e (diff) |
Add text cursor support.
This turned out to be much more complex than anticipated, and the
potential for bugs is therefore quite high.
Diffstat (limited to 'src/unicode.c')
-rw-r--r-- | src/unicode.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/unicode.c b/src/unicode.c index 7ddc0d5..4560d50 100644 --- a/src/unicode.c +++ b/src/unicode.c @@ -18,6 +18,11 @@ uint32_t utf8_to_utf32_validate(const char *s) return g_utf8_get_char_validated(s, -1); } +uint32_t *utf8_string_to_utf32_string(const char *s) +{ + return g_utf8_to_ucs4_fast(s, -1, NULL); +} + uint32_t utf32_isprint(uint32_t c) { return g_unichar_isprint(c); @@ -53,6 +58,15 @@ uint32_t utf32_tolower(uint32_t c) return g_unichar_tolower(c); } +size_t utf32_strlen(const uint32_t *s) +{ + size_t len = 0; + while (s[len] != U'\0') { + len++; + } + return len; +} + char *utf8_next_char(const char *s) { return g_utf8_next_char(s); |