Browse Source

fixed windows unicode printf: set default output to utf8

Nicolas Cannasse 6 năm trước cách đây
mục cha
commit
3c6164d88a
1 tập tin đã thay đổi với 3 bổ sung0 xóa
  1. 3 0
      src/std/sys.c

+ 3 - 0
src/std/sys.c

@@ -37,6 +37,8 @@
 #	include <windows.h>
 #	include <direct.h>
 #	include <conio.h>
+#	include <fcntl.h>
+#	include <io.h>
 #	define getenv _wgetenv
 #	define putenv _wputenv
 #	define getcwd(buf,size) (void*)(int_val)GetCurrentDirectoryW(size,buf)
@@ -599,6 +601,7 @@ HL_PRIM void hl_sys_init(void **args, int nargs, void *hlfile) {
 	hl_file = hlfile;
 #	ifdef HL_WIN
 	setlocale(LC_CTYPE, ""); // printf to current locale
+	_setmode(_fileno(stdout),_O_U8TEXT); // set output to utf8
 #	endif
 }