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
This commit is contained in:
Marcel Raad 2019-04-12 22:59:40 +02:00
parent a55c835e6b
commit 9e5669f388
No known key found for this signature in database
GPG key ID: 33C416EFAE4D6F02
4 changed files with 25 additions and 11 deletions

View file

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -481,6 +481,8 @@ typedef int sig_atomic_t;
#ifdef __VMS
#define argv_item_t __char_ptr32
#elif defined(_UNICODE)
#define argv_item_t wchar_t *
#else
#define argv_item_t char *
#endif