aboutsummaryrefslogtreecommitdiffstats
path: root/src/path.c
diff options
context:
space:
mode:
authorDenis Krjuchkov <denis@crazydev.net>2011-10-22 00:57:30 +0600
committerMax Kellermann <max@duempel.org>2011-10-23 16:29:58 +0200
commit6452461c3903139c7bbed3d1eb2705bf1dde656f (patch)
tree284609d9fc9c0ff512f26bc0aa721995618e2634 /src/path.c
parentc30c46cd5f0d1f857fc38a335ca499cc024e0c80 (diff)
downloadmpd-6452461c3903139c7bbed3d1eb2705bf1dde656f.tar.gz
mpd-6452461c3903139c7bbed3d1eb2705bf1dde656f.tar.xz
mpd-6452461c3903139c7bbed3d1eb2705bf1dde656f.zip
path: autodetect filesystem encoding on Win32
WinAPI explicitly declares filesystem encoding. It can be determined by GetACP(). Use that instead of Glib routine that always "detects" UTF-8 on Win32, which is incorrect for MPD case.
Diffstat (limited to 'src/path.c')
-rw-r--r--src/path.c16
1 files changed, 16 insertions, 0 deletions
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 <assert.h>
#include <string.h>
+#ifdef G_OS_WIN32
+#include <windows.h> // for GetACP()
+#include <stdio.h> // 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 <gstdio.h> helpers are used.
+ * MPD uses regular <stdio.h> functions.
+ * Those functions use encoding determined by GetACP(). */
+ char win_charset[13];
+ sprintf(win_charset, "cp%u", GetACP());
+ charset = win_charset;
+#endif
}
if (charset) {