Skip to content

Unicode support: automatically widen on windows when option is assigned a std::filesystem::path #875

@jmarrec

Description

@jmarrec

I've seen #804, and it does widen in check_path for the CLI:ExistingXXXX validator. https://github.com/CLIUtils/CLI11/pull/804/files#diff-212772a3245e02e1fb8bf60ed69b5c89eb1b4f109e459b3294ff1edbd6c6aa27R131

Assuming this MCVE

#include <CLI/CLI.hpp>
#include <fmt/format.h>
#include <fmt/std.h>     // Formatting std::filesystem::path

#include <filesystem>

namespace fs = std::filesystem;

int main(int argc, char** argv) {

  CLI::App app("test path");
  fs::path dir;
  app.add_option("DIR", dir, "Directory")->check(CLI::ExistingDirectory);

  CLI11_PARSE(app);

  fmt::print("{} - {}\n", dir, fs::exists(dir));
}

In the resulting executable directory:

mkdir voilà
./test voilà

Ideally that would work on both unix and windows.

On windows, the CLI:ExistingDirectory is perfectly fine since it does widden when checking, but the resulting fs::path dir doesn't exist and it prints "térmica" - false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions