From 0bbefca8753dc607b27bda5eb6d09c0ada0deb54 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 24 Jul 2019 14:49:00 +0300 Subject: [PATCH] Windows: unicode command line --- compiler/main.v | 1 + compiler/msvc_win.v | 1 + vlib/os/os.v | 13 +++++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/compiler/main.v b/compiler/main.v index 3977757374..6b5f9e4b53 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -193,6 +193,7 @@ fn (v mut V) compile() { #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include +#include #include // _waccess #include // _O_U8TEXT #include // _wgetcwd diff --git a/compiler/msvc_win.v b/compiler/msvc_win.v index df46c80f72..715536c9dc 100644 --- a/compiler/msvc_win.v +++ b/compiler/msvc_win.v @@ -6,6 +6,7 @@ import os #flag windows @VROOT/thirdparty/microsoft_craziness/microsoft_craziness.o #flag windows -l ole32 #flag windows -l oleaut32 +#flag windows -l shell32 // Emily: If these arent included then msvc assumes that // these return int (which should be 64bit) diff --git a/vlib/os/os.v b/vlib/os/os.v index 73664e9a83..b2c97d5684 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -93,8 +93,17 @@ fn todo_remove(){} fn init_os_args(argc int, argv *byteptr) []string { mut args := []string - for i := 0; i < argc; i++ { - args << string(argv[i]) + $if windows { + mut args_list := &voidptr(0) + mut args_count := 0 + args_list = C.CommandLineToArgvW(C.GetCommandLine(), &args_count) + for i := 0; i < args_count; i++ { + args << string_from_wide(&u16(args_list[i])) + } + } $else { + for i := 0; i < argc; i++ { + args << string(argv[i]) + } } return args }