diff --git a/NEWS b/NEWS index b2bd52da4..f91548813 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ ver 0.16.6 (2010/??/??) * event_pipe: fix WIN32 regression * define WINVER in ./configure +* WIN32: autodetect filesystem encoding ver 0.16.5 (2010/10/09) diff --git a/src/path.c b/src/path.c index 5e39c1636..d1b9ad6ee 100644 --- a/src/path.c +++ b/src/path.c @@ -27,6 +27,11 @@ #include #include +#ifdef G_OS_WIN32 +#include // for GetACP() +#include // for sprintf() +#endif + #undef G_LOG_DOMAIN #define G_LOG_DOMAIN "path" @@ -85,11 +90,22 @@ void path_global_init(void) charset = config_get_string(CONF_FS_CHARSET, NULL); if (charset == NULL) { +#ifndef G_OS_WIN32 const gchar **encodings; g_get_filename_charsets(&encodings); if (encodings[0] != NULL && *encodings[0] != '\0') charset = encodings[0]; +#else /* G_OS_WIN32 */ + /* Glib claims that file system encoding is always utf-8 + * on native Win32 (i.e. not Cygwin). + * However this is true only if helpers are used. + * MPD uses regular functions. + * Those functions use encoding determined by GetACP(). */ + char win_charset[13]; + sprintf(win_charset, "cp%u", GetACP()); + charset = win_charset; +#endif } if (charset) {