diff --git a/glib/gunidecomp.c b/glib/gunidecomp.c index 22ca972f7..dbba10cef 100644 --- a/glib/gunidecomp.c +++ b/glib/gunidecomp.c @@ -625,6 +625,13 @@ compose_hangul_step (gunichar a, * If @ch is not decomposable, *@a is set to @ch and *@b * is set to zero. * + * Note that the way Unicode decomposition pairs are + * defined, it is guaranteed that @b would not decompose + * further, but @a may itself decompose. To get the full + * canonical decomposition for @ch, one would need to + * recursively call this function on @a. Or use + * g_unicode_canonical_decomposition(). + * * See UAX#15 * for details. * diff --git a/glib/tests/unicode.c b/glib/tests/unicode.c index 68533dcc5..8a43388bc 100644 --- a/glib/tests/unicode.c +++ b/glib/tests/unicode.c @@ -525,6 +525,21 @@ test_canonical_decomposition (void) TEST2 (0xCE20, 0x110E, 0x1173); } +static void +test_decompose_tail (void) +{ + gunichar ch, a, b, c, d; + + /* Test that whenever a char ch decomposes into a and b, b itself + * won't decompose any further. */ + + for (ch = 0; ch < 0x110000; ch++) + if (g_unichar_decompose (ch, &a, &b)) + g_assert (!g_unichar_decompose (b, &c, &d)); + else + g_assert (a == ch && b == 0); +} + int main (int argc, char *argv[]) @@ -543,6 +558,7 @@ main (int argc, g_test_add_func ("/unicode/compose", test_compose); g_test_add_func ("/unicode/decompose", test_decompose); g_test_add_func ("/unicode/canonical-decomposition", test_canonical_decomposition); + g_test_add_func ("/unicode/decompose-tail", test_decompose_tail); return g_test_run(); }