CLIUtils / CLI11

CLI11 is a command line parser for C++11 and beyond that provides a rich feature set with a simple and intuitive interface.
https://cliutils.github.io/CLI11/book/
Other
3.35k stars 350 forks source link

UTF8/Unicode config filename not supported on Windows #912

Open r2d3 opened 1 year ago

r2d3 commented 1 year ago

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.
r2d3 commented 1 year ago

I tried using CLI11 version including #875 #878, but this does not solve this issue

phlptp commented 1 year ago

What is the code you are using to parse the arguments?

r2d3 commented 1 year ago

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;
}
r2d3 commented 1 year ago

I am using Git bash to do the cp command with accentuated characters

bindreams commented 1 year ago

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: