mirror of
https://github.com/curl/curl.git
synced 2026-07-31 18:28:05 +03:00
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:
parent
a55c835e6b
commit
9e5669f388
4 changed files with 25 additions and 11 deletions
|
|
@ -2248,20 +2248,22 @@ ParameterError parse_args(struct GlobalConfig *global, int argc,
|
|||
struct OperationConfig *config = global->first;
|
||||
|
||||
for(i = 1, stillflags = TRUE; i < argc && !result; i++) {
|
||||
orig_opt = argv[i];
|
||||
orig_opt = curlx_convert_tchar_to_UTF8(argv[i]);
|
||||
|
||||
if(stillflags && ('-' == argv[i][0])) {
|
||||
if(stillflags && ('-' == orig_opt[0])) {
|
||||
bool passarg;
|
||||
char *flag = argv[i];
|
||||
|
||||
if(!strcmp("--", argv[i]))
|
||||
if(!strcmp("--", orig_opt))
|
||||
/* This indicates the end of the flags and thus enables the
|
||||
following (URL) argument to start with -. */
|
||||
stillflags = FALSE;
|
||||
else {
|
||||
char *nextarg = (i < (argc - 1)) ? argv[i + 1] : NULL;
|
||||
char *nextarg = (i < (argc - 1))
|
||||
? curlx_convert_tchar_to_UTF8(argv[i + 1])
|
||||
: NULL;
|
||||
|
||||
result = getparameter(flag, nextarg, &passarg, global, config);
|
||||
result = getparameter(orig_opt, nextarg, &passarg, global, config);
|
||||
curlx_unicodefree(nextarg);
|
||||
config = global->last;
|
||||
if(result == PARAM_NEXT_OPERATION) {
|
||||
/* Reset result as PARAM_NEXT_OPERATION is only used here and not
|
||||
|
|
@ -2297,7 +2299,7 @@ ParameterError parse_args(struct GlobalConfig *global, int argc,
|
|||
bool used;
|
||||
|
||||
/* Just add the URL please */
|
||||
result = getparameter((char *)"--url", argv[i], &used, global,
|
||||
result = getparameter("--url", orig_opt, &used, global,
|
||||
config);
|
||||
}
|
||||
}
|
||||
|
|
@ -2314,5 +2316,6 @@ ParameterError parse_args(struct GlobalConfig *global, int argc,
|
|||
helpf(global->errors, "%s\n", reason);
|
||||
}
|
||||
|
||||
curlx_unicodefree(orig_opt);
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue