diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2015-08-12 17:11:03 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2015-08-12 17:11:03 -0300 |
commit | c34b57407388748016058c7793f98d75fbd9d211 (patch) | |
tree | d54732f4cf49e283cc0f47f48f3ab36f657ea3cf | |
parent | e42d78007e2e77fda20b654681f4038ba43ee9cc (diff) | |
parent | cea591181d58d7cc161fc9ab1407ce940a421925 (diff) |
Merge pull request #223 from eworm-de/langinfo
simplify UTF-8 detection
-rw-r--r-- | CRT.c | 13 | ||||
-rw-r--r-- | htop.c | 14 |
2 files changed, 5 insertions, 22 deletions
@@ -16,6 +16,7 @@ in the source distribution for its full text. #include <stdlib.h> #include <string.h> #include <locale.h> +#include <langinfo.h> #define ColorPair(i,j) COLOR_PAIR((7-i)*8+j) @@ -585,15 +586,11 @@ void CRT_init(int delay, int colorScheme) { CRT_colorScheme = 1; CRT_setColors(CRT_colorScheme); + /* initialize locale */ + setlocale(LC_CTYPE, ""); + #ifdef HAVE_LIBNCURSESW - char *locale = setlocale(LC_ALL, NULL); - if (locale == NULL || locale[0] == '\0') - locale = setlocale(LC_CTYPE, NULL); - if (locale != NULL && - (strstr(locale, "UTF-8") || - strstr(locale, "utf-8") || - strstr(locale, "UTF8") || - strstr(locale, "utf8"))) + if(strcmp(nl_langinfo(CODESET), "UTF-8") == 0) CRT_utf8 = true; else CRT_utf8 = false; @@ -184,20 +184,6 @@ int main(int argc, char** argv) { } #endif -#ifdef HAVE_LIBNCURSESW - char *locale = setlocale(LC_ALL, NULL); - if (locale == NULL || locale[0] == '\0') - locale = setlocale(LC_CTYPE, NULL); - if (locale != NULL && - (strstr(locale, "UTF-8") || - strstr(locale, "utf-8") || - strstr(locale, "UTF8") || - strstr(locale, "utf8"))) - CRT_utf8 = true; - else - CRT_utf8 = false; -#endif - Process_setupColumnWidths(); UsersTable* ut = UsersTable_new(); |