Commit c34b5740 authored by Hisham Muhammad's avatar Hisham Muhammad
Browse files

Merge pull request #223 from eworm-de/langinfo

simplify UTF-8 detection
parents e42d7800 cea59118
...@@ -16,6 +16,7 @@ in the source distribution for its full text. ...@@ -16,6 +16,7 @@ in the source distribution for its full text.
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <locale.h> #include <locale.h>
#include <langinfo.h>
#define ColorPair(i,j) COLOR_PAIR((7-i)*8+j) #define ColorPair(i,j) COLOR_PAIR((7-i)*8+j)
...@@ -585,15 +586,11 @@ void CRT_init(int delay, int colorScheme) { ...@@ -585,15 +586,11 @@ void CRT_init(int delay, int colorScheme) {
CRT_colorScheme = 1; CRT_colorScheme = 1;
CRT_setColors(CRT_colorScheme); CRT_setColors(CRT_colorScheme);
/* initialize locale */
setlocale(LC_CTYPE, "");
#ifdef HAVE_LIBNCURSESW #ifdef HAVE_LIBNCURSESW
char *locale = setlocale(LC_ALL, NULL); if(strcmp(nl_langinfo(CODESET), "UTF-8") == 0)
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; CRT_utf8 = true;
else else
CRT_utf8 = false; CRT_utf8 = false;
......
...@@ -184,20 +184,6 @@ int main(int argc, char** argv) { ...@@ -184,20 +184,6 @@ int main(int argc, char** argv) {
} }
#endif #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(); Process_setupColumnWidths();
UsersTable* ut = UsersTable_new(); UsersTable* ut = UsersTable_new();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment