UTF8/Unicode config filename not supported on Windows
If I create a config filename with non ascii characters,
./my_app --print > déjà
When I call: ./my_app --config déjà, I got:
my_app-cli.exe --config déjà
déjà was not readable (missing?)
Run with --help for more information.
I tried using CLI11 version including #875 #878, but this does not solve this issue
What is the code you are using to parse the arguments?
Here is the code to reproduce cli11_bug912.tgz
And the command:
# Non accentuated config works
$ cli11_bug --print foo > config
$ cli11_bug -c config
foo
$ cp config déjà
$ cli11_bug -c déjà
déjà was not readable (missing?)
Run with --help for more information.
#include <CLI/CLI.hpp>
#include <iostream>
#include <string>
#ifdef _WIN32
int wmain(int argc, wchar_t* argv[])
#else
int main(int argc, char* argv[])
#endif
{
std::string filename;
CLI::App app("cli11_bug");
app.set_config("-c,--config");
app.add_flag("--print", "Print configuration and exit")->configurable(false);
app.add_option("file", filename, "File to process");
CLI11_PARSE(app);
if (app.get_option("--print")->as<bool>())
{
std::cout << app.config_to_str(true, true);
return 0;
}
std::cout << filename << std::endl;
return 0;
}
I am using Git bash to do the cp command with accentuated characters
So far I was unable to reproduce this, neither on git bash, nor on powershell 5/7, nor on command prompt.
From experience, Unicode on Windows can get corrupted at a number of stages. Could you check a couple of settings for me:
- What terminal are you using? Normal windows terminal is cohost.exe, if you are running in Windows Terminal it's wt.exe, and I believe Git suggests MSYS2-style terminal which is MinTTY.
- Does your Windows installation have this checkmark set:
- Can you reproduce this bug if repeating all the steps from PowerShell 7.x instead of Git bash?