diff options
author | Marcel Raad <Marcel.Raad@teamviewer.com> | 2019-04-12 22:59:40 +0200 |
---|---|---|
committer | Marcel Raad <Marcel.Raad@teamviewer.com> | 2020-05-14 18:13:36 +0200 |
commit | 9e5669f3880674de262000e772ef21ec0cc874be (patch) | |
tree | 3f1f6e7353b5d807b164a7443c85840d47f5c8bf /src/tool_operate.c | |
parent | a55c835e6b99f96e595ad11888a2714447998378 (diff) | |
download | curl-9e5669f3880674de262000e772ef21ec0cc874be.tar.gz |
tool: support UTF-16 command line on Windows
- use `wmain` instead of `main` when `_UNICODE` is defined [0]
- define `argv_item_t` as `wchar_t *` in this case
- use the curl_multibyte gear to convert the command-line arguments to
UTF-8
This makes it possible to pass parameters with characters outside of
the current locale on Windows, which is required for some tests, e.g.
the IDN tests. Out of the box, this currently only works with the
Visual Studio project files, which default to Unicode, and winbuild
with the `ENABLE_UNICODE` option.
[0] https://devblogs.microsoft.com/oldnewthing/?p=40643
Ref: https://github.com/curl/curl/issues/3747
Closes https://github.com/curl/curl/pull/3784
Diffstat (limited to 'src/tool_operate.c')
-rw-r--r-- | src/tool_operate.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/tool_operate.c b/src/tool_operate.c index 6d489aa30..0ddcf8ea9 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -2427,6 +2427,7 @@ static CURLcode run_all_transfers(struct GlobalConfig *global, CURLcode operate(struct GlobalConfig *global, int argc, argv_item_t argv[]) { CURLcode result = CURLE_OK; + char *first_arg = curlx_convert_tchar_to_UTF8(argv[1]); /* Setup proper locale from environment */ #ifdef HAVE_SETLOCALE @@ -2435,8 +2436,8 @@ CURLcode operate(struct GlobalConfig *global, int argc, argv_item_t argv[]) /* Parse .curlrc if necessary */ if((argc == 1) || - (!curl_strequal(argv[1], "-q") && - !curl_strequal(argv[1], "--disable"))) { + (!curl_strequal(first_arg, "-q") && + !curl_strequal(first_arg, "--disable"))) { parseconfig(NULL, global); /* ignore possible failure */ /* If we had no arguments then make sure a url was specified in .curlrc */ @@ -2446,6 +2447,8 @@ CURLcode operate(struct GlobalConfig *global, int argc, argv_item_t argv[]) } } + curlx_unicodefree(first_arg); + if(!result) { /* Parse the command line arguments */ ParameterError res = parse_args(global, argc, argv); |