ソースを参照

only switch unicode mode of stdout when doing sys_print (close #251)

Nicolas Cannasse 6 年 前
コミット
1b7449ba1d
1 ファイル変更8 行追加2 行削除
  1. 8 2
      src/std/sys.c

+ 8 - 2
src/std/sys.c

@@ -143,8 +143,16 @@ HL_PRIM void hl_sys_print( vbyte *msg ) {
 #	ifdef HL_XBO
 	OutputDebugStringW((LPCWSTR)msg);
 #	else
+
+#	ifdef HL_WIN_DESKTOP
+	_setmode(_fileno(stdout),_O_U8TEXT);
+#	endif
 	uprintf(USTR("%s"),(uchar*)msg);
 	fflush(stdout);
+#	ifdef HL_WIN_DESKTOP
+	_setmode(_fileno(stdout),_O_TEXT);
+#	endif
+
 #	endif
 	hl_blocking(false);
 }
@@ -601,8 +609,6 @@ HL_PRIM void hl_sys_init(void **args, int nargs, void *hlfile) {
 	hl_file = hlfile;
 #	ifdef HL_WIN_DESKTOP
 	setlocale(LC_CTYPE, ""); // printf to current locale
-	_setmode(_fileno(stdout),_O_U8TEXT); // set output to utf8
-	_setmode(_fileno(stderr),_O_U8TEXT);
 #	endif
 }