On Thu, May 03, 2018 at 07:28:27AM -0400, Frediano Ziglio wrote: > > > > 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 > > > > Stupid questions: what happens if the directory name has like Chines/Japanese > characters and current locale is latin 1 kind of (like western European) ? > Maybe would be better to attempt to use short names if possible (in Windows > a file can have 2 names, one long and one short, usually the short is less > of a problem as DOS compatible). This is exactly what g_win32_locale_filename_from_utf8() does if needed: "On NT-based Windows, on NTFS file systems, file names are in Unicode. It is quite possible that Unicode file names contain characters not representable in the system codepage. (For instance, Greek or Cyrillic characters on Western European or US Windows installations, or various less common CJK characters on CJK Windows installations.) In such a case, and if the filename refers to an existing file, and the file system stores alternate short (8.3) names for directory entries, the short form of the filename is returned. Note that the "short" name might in fact be longer than the Unicode name if the Unicode name has very short pathname components containing non-ASCII characters. If no system codepage name for the file is possible, NULL is returned." Christophe > > I suppose from the code g_win32_get_package_installation_directory_of_module > returns utf-8 encoded path. > > > [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"); > > } > > Frediano > _______________________________________________ > Spice-devel mailing list > Spice-devel@xxxxxxxxxxxxxxxxxxxxx > https://lists.freedesktop.org/mailman/listinfo/spice-devel
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel