windows: Unicode input in REPL
							parent
							
								
									f042dfb861
								
							
						
					
					
						commit
						f1bb25bfaf
					
				|  | @ -355,6 +355,10 @@ fn (v mut V) generate_main() { | ||||||
| 		// vlib can't have `init_consts()`
 | 		// vlib can't have `init_consts()`
 | ||||||
| 		cgen.genln('void init_consts() { | 		cgen.genln('void init_consts() { | ||||||
| #ifdef _WIN32 | #ifdef _WIN32 | ||||||
|  | DWORD consoleMode; | ||||||
|  | BOOL isConsole = GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &consoleMode); | ||||||
|  | int mode = isConsole ? _O_U16TEXT : _O_U8TEXT; | ||||||
|  | _setmode(_fileno(stdin), mode); | ||||||
| _setmode(_fileno(stdout), _O_U8TEXT); | _setmode(_fileno(stdout), _O_U8TEXT); | ||||||
| SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), ENABLE_PROCESSED_OUTPUT | 0x0004); | SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), ENABLE_PROCESSED_OUTPUT | 0x0004); | ||||||
| // ENABLE_VIRTUAL_TERMINAL_PROCESSING
 | // ENABLE_VIRTUAL_TERMINAL_PROCESSING
 | ||||||
|  |  | ||||||
|  | @ -292,8 +292,7 @@ pub fn (v mut V) cc_msvc() { | ||||||
| 		'oleaut32.lib', | 		'oleaut32.lib', | ||||||
| 		'uuid.lib', | 		'uuid.lib', | ||||||
| 		'odbc32.lib', | 		'odbc32.lib', | ||||||
| 		'odbccp32.lib', | 		'odbccp32.lib' | ||||||
| 		'vcruntime.lib', |  | ||||||
| 	] | 	] | ||||||
| 
 | 
 | ||||||
| 	mut inc_paths := []string{} | 	mut inc_paths := []string{} | ||||||
|  |  | ||||||
|  | @ -1,3 +1,7 @@ | ||||||
| println('hello world') | println('Hello, world!') | ||||||
|  | println('Привет, мир!') | ||||||
|  | println('你好世界') | ||||||
| ===output=== | ===output=== | ||||||
| hello world | Hello, world! | ||||||
|  | Привет, мир! | ||||||
|  | 你好世界 | ||||||
|  |  | ||||||
							
								
								
									
										11
									
								
								make.bat
								
								
								
								
							
							
						
						
									
										11
									
								
								make.bat
								
								
								
								
							|  | @ -34,8 +34,9 @@ if %ERRORLEVEL% NEQ 0 ( | ||||||
|     exit /b 1 |     exit /b 1 | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| echo Building v.v... | echo rebuild from source (twice, in case of C definitions changes) | ||||||
| v2.exe -o v.exe compiler | v2.exe -o v3.exe compiler | ||||||
|  | v3.exe -o v.exe -prod compiler | ||||||
| if %ERRORLEVEL% NEQ 0 ( | if %ERRORLEVEL% NEQ 0 ( | ||||||
|     echo v.exe failed to compile itself - Create an issue at 'https://github.com/vlang' |     echo v.exe failed to compile itself - Create an issue at 'https://github.com/vlang' | ||||||
|     exit /b 1 |     exit /b 1 | ||||||
|  | @ -66,14 +67,16 @@ if %ERRORLEVEL% NEQ 0 ( | ||||||
|     goto :compileerror |     goto :compileerror | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| echo rebuild from source | echo rebuild from source (twice, in case of C definitions changes) | ||||||
| v2.exe -os msvc -o v.exe compiler | v2.exe -os msvc -o v3.exe compiler | ||||||
|  | v3.exe -os msvc -o v.exe -prod compiler | ||||||
| if %ERRORLEVEL% NEQ 0 ( | if %ERRORLEVEL% NEQ 0 ( | ||||||
|     echo V failed to build itself |     echo V failed to build itself | ||||||
|     goto :compileerror |     goto :compileerror | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| del v2.exe | del v2.exe | ||||||
|  | del v3.exe | ||||||
| rd /s /q vc | rd /s /q vc | ||||||
| 
 | 
 | ||||||
| goto :success | goto :success | ||||||
|  |  | ||||||
|  | @ -469,10 +469,10 @@ pub fn get_line() string { | ||||||
| pub fn get_raw_line() string { | pub fn get_raw_line() string { | ||||||
| 	$if windows { | 	$if windows { | ||||||
|         maxlinechars := 256 |         maxlinechars := 256 | ||||||
|         buf := &u16(malloc(maxlinechars*2)) |         buf := &byte(malloc(maxlinechars*2)) | ||||||
|         res := int( C.fgetws(buf, maxlinechars, C.stdin ) ) |         res := int( C.fgetws(buf, maxlinechars, C.stdin ) ) | ||||||
|         len := int(  C.wcslen(buf) ) |         len := int(  C.wcslen(&u16(buf)) ) | ||||||
|         if 0 != res { return string_from_wide2( buf, len ) } |         if 0 != res { return string_from_wide2( &u16(buf), len ) } | ||||||
|         return '' |         return '' | ||||||
|     } |     } | ||||||
| 	$else { | 	$else { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue