diff --git a/CRT.c b/CRT.c index 983c601f..03f71ca7 100644 --- a/CRT.c +++ b/CRT.c @@ -16,6 +16,7 @@ in the source distribution for its full text. #include #include #include +#include #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; diff --git a/htop.c b/htop.c index 211489bb..a031cde3 100644 --- a/htop.c +++ b/htop.c @@ -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();