Merge branch 'fix_g_unichar_totitle' into 'master'

Fix g unichar totitle

Closes #135

See merge request GNOME/glib!843
This commit is contained in:
Philip Withnall 2019-05-14 12:05:30 +00:00
commit 4f5fe35385
2 changed files with 8 additions and 1 deletions

View File

@ -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);

View File

@ -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);