From 438c1add9de7aff5968add3b9e02fac30a62e74a Mon Sep 17 00:00:00 2001 From: "J. Alexander Treuman" Date: Mon, 8 Jan 2007 04:31:44 +0000 Subject: Convert log messages sent to stdout to the current locale's charset. git-svn-id: https://svn.musicpd.org/mpd/trunk@5227 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/localization.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/localization.c') diff --git a/src/localization.c b/src/localization.c index 23250a6a9..f2f51d911 100644 --- a/src/localization.c +++ b/src/localization.c @@ -17,6 +17,7 @@ */ #include "localization.h" +#include "charConv.h" #include "utils.h" #include @@ -30,6 +31,19 @@ static char *localeCharset = NULL; +char *utf8ToLocaleCharset(char *str) +{ + static char *ret = NULL; + + if (localeCharset) + ret = convCharset(localeCharset, "UTF-8", str, ret); + + if (!ret) + ret = xstrdup(str); + + return ret; +} + void setLocaleCharset(char *charset) { if (localeCharset) @@ -63,7 +77,7 @@ void initLocalization(void) strcmp(currentLocale, "POSIX") == 0) { WARNING("current locale is \"%s\"\n", currentLocale); - setLocaleCharset(xstrdup("")); + setLocaleCharset(xstrdup("ISO-8859-1")); } else if ((temp = nl_langinfo(CODESET))) { setLocaleCharset(xstrdup(temp)); } else { -- cgit v1.2.3