|
|
|
@ -774,15 +774,14 @@ init_banner(const notcurses* nc){
|
|
|
|
|
// practice is for the client code to have called setlocale() themselves, and
|
|
|
|
|
// set the NCOPTION_INHIBIT_SETLOCALE flag. if that flag is set, we take the
|
|
|
|
|
// locale as we get it.
|
|
|
|
|
static void
|
|
|
|
|
init_lang(const notcurses_options* opts){
|
|
|
|
|
if(!(opts->flags & NCOPTION_INHIBIT_SETLOCALE)){
|
|
|
|
|
const char* locale = setlocale(LC_ALL, "");
|
|
|
|
|
if(locale && (!strcmp(locale, "C") || !strcmp(locale, "POSIX"))){
|
|
|
|
|
const char* lang = getenv("LANG");
|
|
|
|
|
if(lang){
|
|
|
|
|
// if LANG was explicitly set to C/POSIX, roll with it
|
|
|
|
|
if(strcmp(locale, "C") && strcmp(locale, "POSIX")){
|
|
|
|
|
void init_lang(int verbose){
|
|
|
|
|
const char* locale = setlocale(LC_ALL, "");
|
|
|
|
|
if(locale && (!strcmp(locale, "C") || !strcmp(locale, "POSIX"))){
|
|
|
|
|
const char* lang = getenv("LANG");
|
|
|
|
|
if(lang){
|
|
|
|
|
// if LANG was explicitly set to C/POSIX, roll with it
|
|
|
|
|
if(strcmp(locale, "C") && strcmp(locale, "POSIX")){
|
|
|
|
|
if(verbose){
|
|
|
|
|
if(!locale){ // otherwise, generate diagnostic
|
|
|
|
|
fprintf(stderr, "Couldn't set locale based off LANG %s\n", lang);
|
|
|
|
|
}else{
|
|
|
|
@ -790,9 +789,9 @@ init_lang(const notcurses_options* opts){
|
|
|
|
|
lang ? lang : "???");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
fprintf(stderr, "No LANG environment variable was set, ick :/\n");
|
|
|
|
|
}
|
|
|
|
|
}else if(verbose){
|
|
|
|
|
fprintf(stderr, "No LANG environment variable was set, ick :/\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -842,7 +841,9 @@ notcurses* notcurses_init(const notcurses_options* opts, FILE* outfp){
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
ret->loglevel = opts->loglevel;
|
|
|
|
|
init_lang(opts);
|
|
|
|
|
if(!(opts->flags & NCOPTION_INHIBIT_SETLOCALE)){
|
|
|
|
|
init_lang(true);
|
|
|
|
|
}
|
|
|
|
|
const char* encoding = nl_langinfo(CODESET);
|
|
|
|
|
if(encoding && strcmp(encoding, "UTF-8") == 0){
|
|
|
|
|
ret->utf8 = true;
|
|
|
|
|