detect system charset encoding automatically

This commit is contained in:
Andrzej Rybczak
2009-09-19 22:22:12 +02:00
parent f0b2c690ef
commit 310ea04f3e
3 changed files with 17 additions and 2 deletions

View File

@@ -38,6 +38,7 @@ dnl ================================
dnl = checking for various headers = dnl = checking for various headers =
dnl ================================ dnl ================================
AC_CHECK_HEADERS([dirent.h regex.h], , AC_MSG_ERROR(vital headers missing)) AC_CHECK_HEADERS([dirent.h regex.h], , AC_MSG_ERROR(vital headers missing))
AC_CHECK_HEADERS([langinfo.h], , AC_MSG_WARN(locale detection disabled))
dnl ====================== dnl ======================
dnl = checking for iconv = dnl = checking for iconv =

View File

@@ -43,8 +43,13 @@
# #
##### system encoding ##### ##### system encoding #####
## ##
## if you use encoding other than utf8, set it in ## ncmpcpp should detect your charset encoding
## order to handle utf8 encoded strings properly. ## but if it failed to do so, you can specify
## charset encoding you are using here.
##
## Note: Since MPD uses utf8 by default, setting
## this option makes sense only if your encoding
## is different.
## ##
# #
#system_encoding = "" #system_encoding = ""

View File

@@ -31,6 +31,10 @@
#include "lyrics.h" #include "lyrics.h"
#include "settings.h" #include "settings.h"
#ifdef HAVE_LANGINFO_H
# include <langinfo.h>
#endif
const std::string config_file = config_dir + "config"; const std::string config_file = config_dir + "config";
const std::string keys_config_file = config_dir + "keys"; const std::string keys_config_file = config_dir + "keys";
@@ -318,6 +322,11 @@ void DefaultConfiguration(ncmpcpp_config &conf)
conf.lyrics_db = 0; conf.lyrics_db = 0;
conf.regex_type = 0; conf.regex_type = 0;
conf.lines_scrolled = 2; conf.lines_scrolled = 2;
# ifdef HAVE_LANGINFO_H
conf.system_encoding = nl_langinfo(CODESET);
if (conf.system_encoding == "UTF-8") // mpd uses utf-8 by default so no need to convert
conf.system_encoding.clear();
# endif // HAVE_LANGINFO_H
} }
void ReadKeys(ncmpcpp_keys &keys) void ReadKeys(ncmpcpp_keys &keys)