]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: unichar - Split off uni_ucs4_decompose_hangul()
authorStephan Bosch <stephan.bosch@open-xchange.com>
Fri, 21 Mar 2025 03:49:57 +0000 (04:49 +0100)
committerStephan Bosch <stephan.bosch@open-xchange.com>
Fri, 1 Aug 2025 01:11:19 +0000 (03:11 +0200)
src/lib/unichar.c

index d29a632feff48e26d7a6797b722b725e5cc6ad9d..62402a48c85285d7a9afbf9a97796d167a60c141 100644 (file)
@@ -289,7 +289,7 @@ static bool uni_ucs4_decompose_uni(unichar_t *chr)
        return TRUE;
 }
 
-static void uni_ucs4_decompose_hangul_utf8(unichar_t chr, buffer_t *output)
+static size_t uni_ucs4_decompose_hangul(unichar_t chr, unichar_t buf[3])
 {
        /* The Unicode Standard, Section 3.12.2:
           Hangul Syllable Decomposition
@@ -311,16 +311,28 @@ static void uni_ucs4_decompose_hangul_utf8(unichar_t chr, buffer_t *output)
        uint32_t v_part = v_base + v_index;
 
        if (t_index == 0) {
-               uni_ucs4_to_utf8_c(l_part, output);
-               uni_ucs4_to_utf8_c(v_part, output);
-               return;
+               buf[0] = l_part;
+               buf[1] = v_part;
+               return 2;
        }
 
        uint32_t t_part = t_base + t_index;
 
-       uni_ucs4_to_utf8_c(l_part, output);
-       uni_ucs4_to_utf8_c(v_part, output);
-       uni_ucs4_to_utf8_c(t_part, output);
+       buf[0] = l_part;
+       buf[1] = v_part;
+       buf[2] = t_part;
+       return 3;
+}
+
+static void uni_ucs4_decompose_hangul_utf8(unichar_t chr, buffer_t *output)
+{
+       unichar_t buf[3];
+       size_t len, i;
+
+       len = uni_ucs4_decompose_hangul(chr, buf);
+
+       for (i = 0; i < len; i++)
+               uni_ucs4_to_utf8_c(buf[i], output);
 }
 
 static bool uni_ucs4_decompose_multi_utf8(unichar_t chr, buffer_t *output)