diff --git a/src/embedding_wrapper.c b/src/embedding_wrapper.c index 18526873..3080ee81 100644 --- a/src/embedding_wrapper.c +++ b/src/embedding_wrapper.c @@ -57,8 +57,23 @@ void set_depot_load_path(const char *root_dir) { // main function (windows UTF16 -> UTF8 argument conversion code copied from // julia's ui/repl.c) +#ifdef _WIN32 +int wmain(int argc, wchar_t *wargv[], wchar_t *envp[]) { + char **argv = (char **)malloc(sizeof(char *) * argc); + if (!argv) return 1; + + for (int i = 0; i < argc; i++) { // write the command line to UTF8 + wchar_t *warg = wargv[i]; + size_t len = WideCharToMultiByte(CP_UTF8, 0, warg, -1, NULL, 0, NULL, NULL); + if (!len) return 1; + char *arg = (char *)malloc(len); + if (!WideCharToMultiByte(CP_UTF8, 0, warg, -1, arg, len, NULL, NULL)) return 1; + argv[i] = arg; + } +#else int main(int argc, char *argv[]) { - argv = uv_setup_args(argc, argv); // no-op on Windows + argv = uv_setup_args(argc, argv); +#endif // Find where eventual julia arguments start int program_argc = argc; diff --git a/src/juliaconfig.jl b/src/juliaconfig.jl index 0d6f2fb0..66eb1673 100644 --- a/src/juliaconfig.jl +++ b/src/juliaconfig.jl @@ -61,6 +61,9 @@ function cflags() if Sys.isunix() print(flags, " -fPIC") end + if Sys.iswindows() + print(flags, " -municode") + end return String(take!(flags)) end diff --git a/test/runtests.jl b/test/runtests.jl index a02e20a0..4ead21bc 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -140,7 +140,7 @@ end rm(joinpath(new_depot, "artifacts"); recursive=true, force=true) end # try app_path(app_name) = abspath(app_compiled_dir, "bin", app_name * (Sys.iswindows() ? ".exe" : "")) - app_output = read(`$(app_path("MyApp")) I get --args --julia-args --threads=3 --check-bounds=yes -O1`, String) + app_output = read(`$(app_path("MyApp")) I get --args áéíóú --julia-args --threads=3 --check-bounds=yes -O1`, String) # Check stdlib filtering if filter == true @@ -159,7 +159,7 @@ end # Check artifact gets run from the correct place @test occursin("HelloWorld artifact at $(realpath(app_compiled_dir))", app_output) # Check ARGS - @test occursin("""ARGS = ["I", "get", "--args"]""", app_output) + @test occursin("""ARGS = ["I", "get", "--args", "áéíóú"]""", app_output) # Check julia-args @test occursin("(Base.JLOptions()).opt_level = 1", app_output) @test occursin("(Base.JLOptions()).nthreads = 3", app_output)