Look for \.UTF-8 only in the first env. var found from LANG, LC_MESSAGES, LC_ALL

This commit is contained in:
Paul LeoNerd Evans 2014-01-05 18:23:46 +00:00
parent 8bed1fdbf0
commit d97617963d
1 changed files with 2 additions and 11 deletions

View File

@ -382,19 +382,10 @@ TermKey *termkey_new(int fd, int flags)
tk->fd = fd; tk->fd = fd;
if(!(flags & (TERMKEY_FLAG_RAW|TERMKEY_FLAG_UTF8))) { if(!(flags & (TERMKEY_FLAG_RAW|TERMKEY_FLAG_UTF8))) {
int locale_is_utf8 = 0;
char *e; char *e;
if((e = getenv("LANG")) && strstr(e, "UTF-8")) if(((e = getenv("LANG")) || (e = getenv("LC_MESSAGES")) || (e = getenv("LC_ALL"))) &&
locale_is_utf8 = 1; strstr(e, "UTF-8"))
if(!locale_is_utf8 && (e = getenv("LC_MESSAGES")) && strstr(e, "UTF-8"))
locale_is_utf8 = 1;
if(!locale_is_utf8 && (e = getenv("LC_ALL")) && strstr(e, "UTF-8"))
locale_is_utf8 = 1;
if(locale_is_utf8)
flags |= TERMKEY_FLAG_UTF8; flags |= TERMKEY_FLAG_UTF8;
else else
flags |= TERMKEY_FLAG_RAW; flags |= TERMKEY_FLAG_RAW;