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;
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);
/* the locale */
if (console.localestr)
if (console.localestr) {
free(console.localestr);
tmpstr = setlocale(LC_ALL, ".UTF8");
if (tmpstr)
console.localestr = dupstr(tmpstr);
console.localestr = NULL;
}
localestr = setlocale(LC_ALL, ".UTF8");
if (localestr)
console.localestr = dupstr(localestr);
/* the code page */
SetConsoleOutputCP(65001);
console.code_page = GetConsoleOutputCP();
@@ -2510,7 +2512,10 @@ void nethack_enter_consoletty(void)
console.orig_code_page = GetConsoleOutputCP();
/* 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 */
console.orig_font_info.cbSize = sizeof(console.orig_font_info);