[Spice-devel] [spice-gtk 3/3] win32: Convert locale dir from UTF-8 to local encoding

Christophe Fergeau cfergeau at redhat.com
Thu May 3 10:02:00 UTC 2018


As indicated in gtk+ win32 gtk_get_localedir [1], bindtextdomain() is not
UTF-8 aware on win32, so it needs a filename in locale encoding

[1] https://gitlab.gnome.org/GNOME/gtk/blob/master/gtk/gtkwin32.c#L187
---
 src/spice-glib-main.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/spice-glib-main.c b/src/spice-glib-main.c
index c2bd7ca6..881015fc 100644
--- a/src/spice-glib-main.c
+++ b/src/spice-glib-main.c
@@ -32,9 +32,13 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
     if (fdwReason == DLL_PROCESS_ATTACH) {
         char *basedir =
             g_win32_get_package_installation_directory_of_module(hinstDLL);
-        char *localedir = g_build_filename(basedir, "share", "locale", NULL);
+        char *utf8_localedir = g_build_filename(basedir, "share", "locale", NULL);
+        /* bindtextdomain's 2nd argument is not UTF-8 aware */
+        char *localedir = g_win32_locale_filename_from_utf8 (utf8_localedir);
+
         bindtextdomain(GETTEXT_PACKAGE, localedir);
         g_free(localedir);
+        g_free(utf8_localedir);
         g_free(basedir);
         bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
     }
-- 
2.17.0



More information about the Spice-devel mailing list