aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-11-05 18:25:57 +0100
committerMax Kellermann <max@duempel.org>2008-11-05 18:25:57 +0100
commit6a7a26fe42b772347833136666b237ad6d8a51dc (patch)
treef1d40331e2f1d767515d94f833e3f957c7273947
parent3002fd18cb6a1e0690ea969e2560373be158526e (diff)
downloadmpd-6a7a26fe42b772347833136666b237ad6d8a51dc.tar.gz
mpd-6a7a26fe42b772347833136666b237ad6d8a51dc.tar.xz
mpd-6a7a26fe42b772347833136666b237ad6d8a51dc.zip
path: get filesystem charset from GLib
GLib provides the function g_get_filename_charsets() which determines the file system character set. This changes MPD's fallback: GLib prefers UTF-8 as a fallback. MPD used to fall back to ISO Latin 1.
Diffstat (limited to '')
-rw-r--r--src/path.c45
1 files changed, 6 insertions, 39 deletions
diff --git a/src/path.c b/src/path.c
index b3af926ba..7e24fbf8f 100644
--- a/src/path.c
+++ b/src/path.c
@@ -23,13 +23,6 @@
#include "playlist.h"
#include "os_compat.h"
-#ifdef HAVE_LOCALE
-#ifdef HAVE_LANGINFO_CODESET
-#include <locale.h>
-#include <langinfo.h>
-#endif
-#endif
-
#include <glib.h>
static char *fs_charset;
@@ -98,42 +91,16 @@ void path_global_init(void)
ConfigParam *fs_charset_param = getConfigParam(CONF_FS_CHARSET);
char *charset = NULL;
- char *originalLocale;
if (fs_charset_param) {
charset = xstrdup(fs_charset_param->value);
+ } else {
+ const gchar **encodings;
+ g_get_filename_charsets(&encodings);
+
+ if (encodings[0] != NULL && *encodings[0] != '\0')
+ charset = g_strdup(encodings[0]);
}
-#ifdef HAVE_LOCALE
-#ifdef HAVE_LANGINFO_CODESET
- else if ((originalLocale = setlocale(LC_CTYPE, NULL))) {
- char *temp;
- char *currentLocale;
- originalLocale = xstrdup(originalLocale);
-
- if (!(currentLocale = setlocale(LC_CTYPE, ""))) {
- WARNING("problems setting current locale with "
- "setlocale()\n");
- } else {
- if (strcmp(currentLocale, "C") == 0 ||
- strcmp(currentLocale, "POSIX") == 0) {
- WARNING("current locale is \"%s\"\n",
- currentLocale);
- } else if ((temp = nl_langinfo(CODESET))) {
- charset = xstrdup(temp);
- } else
- WARNING
- ("problems getting charset for locale\n");
- if (!setlocale(LC_CTYPE, originalLocale)) {
- WARNING
- ("problems resetting locale with setlocale()\n");
- }
- }
-
- free(originalLocale);
- } else
- WARNING("problems getting locale with setlocale()\n");
-#endif
-#endif
if (charset) {
path_set_fs_charset(charset);