windows: more setlocale

This commit is contained in:
nhmall
2023-07-01 09:24:57 -04:00
parent 43079cf72f
commit 5e34883f36

View File

@@ -1911,16 +1911,18 @@ tty_utf8graphics_fixup(void)
{ {
CONSOLE_FONT_INFOEX console_font_info; CONSOLE_FONT_INFOEX console_font_info;
if ((tty_procs.wincap2 & WC2_U_UTF8STR) && SYMHANDLING(H_UTF8)) { if ((tty_procs.wincap2 & WC2_U_UTF8STR) && SYMHANDLING(H_UTF8)) {
char *tmpstr = 0; char *localestr = 0;
if (!console.hConOut) if (!console.hConOut)
console.hConOut = GetStdHandle(STD_OUTPUT_HANDLE); console.hConOut = GetStdHandle(STD_OUTPUT_HANDLE);
/* the locale */ /* the locale */
if (console.localestr) if (console.localestr) {
free(console.localestr); free(console.localestr);
tmpstr = setlocale(LC_ALL, ".UTF8"); console.localestr = NULL;
if (tmpstr) }
console.localestr = dupstr(tmpstr); localestr = setlocale(LC_ALL, ".UTF8");
if (localestr)
console.localestr = dupstr(localestr);
/* the code page */ /* the code page */
SetConsoleOutputCP(65001); SetConsoleOutputCP(65001);
console.code_page = GetConsoleOutputCP(); console.code_page = GetConsoleOutputCP();
@@ -2510,7 +2512,10 @@ void nethack_enter_consoletty(void)
console.orig_code_page = GetConsoleOutputCP(); console.orig_code_page = GetConsoleOutputCP();
/* store the original locale */ /* store the original locale */
console.orig_localestr = dupstr(setlocale(LC_ALL, "")); console.orig_localestr = NULL;
localestr = setlocale(LC_ALL, "");
if (localestr)
console.orig_localestr = dupstr(localestr);
/* store the original font */ /* store the original font */
console.orig_font_info.cbSize = sizeof(console.orig_font_info); console.orig_font_info.cbSize = sizeof(console.orig_font_info);