From 6c47cf7892d0f212b04e7b798e53c120f51022d7 Mon Sep 17 00:00:00 2001 From: Phil Jones Date: Tue, 20 Dec 2022 23:53:20 +0000 Subject: Add text cursor support. This turned out to be much more complex than anticipated, and the potential for bugs is therefore quite high. --- src/unicode.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/unicode.c') 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); -- cgit v1.2.3