diff --git a/eel/eel-string.c b/eel/eel-string.c index 5d70089a8..5cd705f3d 100644 --- a/eel/eel-string.c +++ b/eel/eel-string.c @@ -95,16 +95,28 @@ eel_str_double_underscores (const char *string) char * eel_str_capitalize (const char *string) { - char *capitalized; + char *capitalized = NULL; if (string == NULL) { return NULL; } - capitalized = g_strdup (string); + if (g_utf8_validate (string, -1, NULL)) + { + g_autofree gunichar *ucs4 = NULL; + ucs4 = g_utf8_to_ucs4 (string, -1, NULL, NULL, NULL); + if (ucs4 != NULL) + { + ucs4[0] = g_unichar_toupper (ucs4[0]); + capitalized = g_ucs4_to_utf8 (ucs4, -1, NULL, NULL, NULL); + } + } - capitalized[0] = g_ascii_toupper (capitalized[0]); + if (capitalized == NULL) + { + return g_strdup (string); + } return capitalized; } diff --git a/src/nautilus-app-chooser.c b/src/nautilus-app-chooser.c index af9b127d0..e15abc3ae 100644 --- a/src/nautilus-app-chooser.c +++ b/src/nautilus-app-chooser.c @@ -9,6 +9,8 @@ #include #include +#include + #include "nautilus-file.h" #include "nautilus-signaller.h" @@ -218,8 +220,9 @@ nautilus_app_chooser_constructed (GObject *object) content_type_description = g_content_type_get_description (self->content_type); if (content_type_description != NULL) { - content_type_description[0] = g_ascii_toupper (content_type_description[0]); - adw_action_row_set_subtitle (ADW_ACTION_ROW (self->set_default_row), content_type_description); + g_autofree gchar *capitalized = NULL; + capitalized = eel_str_capitalize (content_type_description); + adw_action_row_set_subtitle (ADW_ACTION_ROW (self->set_default_row), capitalized); } } else