diff --git a/glib/guniprop.c b/glib/guniprop.c index cd3675fbf..9a79e4316 100644 --- a/glib/guniprop.c +++ b/glib/guniprop.c @@ -623,13 +623,19 @@ gunichar g_unichar_totitle (gunichar c) { unsigned int i; + + /* We handle U+0000 explicitely because some elements in + * title_table[i][1] may be null. */ + if (c == 0) + return c; + for (i = 0; i < G_N_ELEMENTS (title_table); ++i) { if (title_table[i][0] == c || title_table[i][1] == c || title_table[i][2] == c) return title_table[i][0]; } - + if (TYPE (c) == G_UNICODE_LOWERCASE_LETTER) return g_unichar_toupper (c); diff --git a/glib/tests/unicode.c b/glib/tests/unicode.c index adf67bab1..3858b7732 100644 --- a/glib/tests/unicode.c +++ b/glib/tests/unicode.c @@ -882,6 +882,7 @@ test_title (void) g_assert_false (g_unichar_istitle (G_UNICODE_LAST_CHAR_PART1)); g_assert_false (g_unichar_istitle (G_UNICODE_LAST_CHAR_PART1 + 1)); + g_assert_cmphex (g_unichar_totitle (0x0000), ==, 0x0000); g_assert_cmphex (g_unichar_totitle (0x01c6), ==, 0x01c5); g_assert_cmphex (g_unichar_totitle (0x01c4), ==, 0x01c5); g_assert_cmphex (g_unichar_totitle (0x01c5), ==, 0x01c5);