=== modified file 'termkey.c' --- termkey.c 2014-01-05 18:23:46 +0000 +++ termkey.c 2013-08-26 17:46:01 +0000 @@ -382,10 +382,19 @@ tk->fd = fd; if(!(flags & (TERMKEY_FLAG_RAW|TERMKEY_FLAG_UTF8))) { + int locale_is_utf8 = 0; char *e; - if(((e = getenv("LANG")) || (e = getenv("LC_MESSAGES")) || (e = getenv("LC_ALL"))) && - strstr(e, "UTF-8")) + if((e = getenv("LANG")) && strstr(e, "UTF-8")) + locale_is_utf8 = 1; + + 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; else flags |= TERMKEY_FLAG_RAW;