--- utf8.c +++ utf8.c @@ -340,10 +340,24 @@ struct charmap *locale_map; struct charmap *locale_map_non_utf8; /* Old, non-utf8 version of locale */ +static void get_language(void) +{ + char *s; + if((s = getenv("LC_ALL")) == NULL) + if((s = getenv("LC_MESSAGES")) == NULL) + s = getenv("LANG"); + + s = (s != NULL) ? zdup(s) : USTR "ascii"; + locale_lang = s; + return; +} + void joe_locale() { unsigned char *s, *t, *u; + get_language(); + s=(unsigned char *)getenv("LC_ALL"); if (!s) { s=(unsigned char *)getenv("LC_CTYPE"); @@ -362,8 +376,6 @@ void joe_locale() if ((t=zrchr(s,'.'))) *t = 0; - locale_lang = s; - #ifdef HAVE_SETLOCALE setlocale(LC_ALL,(char *)s); non_utf8_codeset = zdup((unsigned char *)nl_langinfo(CODESET));