diff --git a/configure.in b/configure.in index 3d0512aa..693de9cb 100644 --- a/configure.in +++ b/configure.in @@ -38,6 +38,7 @@ dnl ================================ dnl = checking for various headers = dnl ================================ 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 = checking for iconv = diff --git a/doc/config b/doc/config index fc59eb81..3f425ca8 100644 --- a/doc/config +++ b/doc/config @@ -43,8 +43,13 @@ # ##### system encoding ##### ## -## if you use encoding other than utf8, set it in -## order to handle utf8 encoded strings properly. +## ncmpcpp should detect your charset encoding +## 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 = "" diff --git a/src/settings.cpp b/src/settings.cpp index 6b019f2b..931a8899 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -31,6 +31,10 @@ #include "lyrics.h" #include "settings.h" +#ifdef HAVE_LANGINFO_H +# include +#endif + const std::string config_file = config_dir + "config"; const std::string keys_config_file = config_dir + "keys"; @@ -318,6 +322,11 @@ void DefaultConfiguration(ncmpcpp_config &conf) conf.lyrics_db = 0; conf.regex_type = 0; 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)