@@ -1427,8 +1427,8 @@ CLI11 supports Unicode and wide strings as defined in the
1427
1427
1428
1428
When using the command line on Windows with unicode arguments, your `main`
1429
1429
function may already receive broken Unicode. Parsing `argv` at that point will
1430
- not give you a correct string. To fix this, you have three good options and two
1431
- bad ones :
1430
+ not give you a correct string. To fix this, you have three options; the first
1431
+ is recommended for cross-platform support :
1432
1432
1433
1433
1\. Replace `argv` with `app.ensure_utf8(argv)` before any arguments are parsed.
1434
1434
`ensure_utf8` will do nothing on systems where `argv` is already in UTF-8 (Such
@@ -1445,40 +1445,13 @@ int main(int argc, char** argv) {
1445
1445
}
1446
1446
```
1447
1447
1448
- 2\. If you pass unmodified command-line arguments to CLI11, call ` app.parse() `
1449
- instead of ` app.parse(argc, argv) ` (or ` CLI11_PARSE(app) ` instead of
1450
- ` CLI11_PARSE(app, argc, argv) ` ). The library will find correct arguments by
1451
- itself.
1448
+ Be sure you do not modify ` argv ` before this function call, as the correct
1449
+ values will be reconstructed using Windows APIs and produced by this call. It
1450
+ has no effect on other platforms and just passes through ` argv ` .
1452
1451
1453
- > [ !NOTE]
1454
- >
1455
- > This approach may not work on weird OS configurations, such as when the
1456
- > ` /proc ` dir is missing on Linux systems (see also
1457
- > [ #845 ] ( https://github.com/CLIUtils/CLI11/issues/845 ) ).
1458
- >
1459
- > ``` cpp
1460
- > int main () {
1461
- > CLI::App app;
1462
- > // ...
1463
- > CLI11_PARSE(app);
1464
- > }
1465
- > ```
1466
-
1467
- 3\. Get correct arguments with which the program was originally executed using
1468
- provided functions: `CLI::argc()` and `CLI::argv()`. These three methods are the
1469
- only cross-platform ways of handling unicode correctly.
1470
-
1471
- ```cpp
1472
- int main() {
1473
- CLI::App app;
1474
- // ...
1475
- CLI11_PARSE(app, CLI::argc(), CLI::argv());
1476
- }
1477
- ```
1478
-
1479
- <details ><summary >Bad options (click to expand)</summary ><p >
1452
+ <details ><summary >Other options (click to expand)</summary ><p >
1480
1453
1481
- 4 \. Use the Windows-only non-standard ` wmain ` function, which accepts
1454
+ 2 \. Use the Windows-only non-standard ` wmain ` function, which accepts
1482
1455
` wchar_t *argv[] ` instead of ` char* argv[] ` . Parsing this will allow CLI to
1483
1456
convert wide strings to UTF-8 without losing information.
1484
1457
@@ -1490,10 +1463,10 @@ int wmain(int argc, wchar_t *argv[]) {
1490
1463
}
1491
1464
```
1492
1465
1493
- 5 \. Retrieve arguments yourself by using Windows APIs like
1466
+ 3 \. Retrieve arguments yourself by using Windows APIs like
1494
1467
[`CommandLineToArgvW`](https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-commandlinetoargvw)
1495
1468
and pass them to CLI. This is what the library is doing under the hood in
1496
- `CLI::argv() `.
1469
+ `ensure_utf8 `.
1497
1470
1498
1471
</p></details>
1499
1472
</br>
0 commit comments