windows: replace deprecated codecvt with fs::u8path #35704

pull kevkevinpal wants to merge 1 commits into bitcoin:master from kevkevinpal:remove-deprecated-codecvt changing 4 files +22 −27
  1. kevkevinpal commented at 9:19 PM on July 12, 2026: contributor

    Summary

    Remove std::wstring_convert/codecvt (deprecated in C++17, removed in C++26) in favor of fs::u8path().wstring() for UTF-8 to wide conversions.

    This should be fine to remove since Bitcoin Core is now on C++20

  2. DrahtBot commented at 9:20 PM on July 12, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35704.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    Concept ACK hebasto

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #34995 (iwyu: Fix warnings in src/common and treat them as errors by hebasto)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  3. fanquake commented at 7:54 AM on July 13, 2026: member
  4. in src/util/exec.cpp:31 in d8e64c1e85
      26 | @@ -29,16 +27,16 @@ int ExecVp(const char* file, char* const argv[])
      27 |      return execvp(file, argv);
      28 |  #else
      29 |      std::vector<std::wstring> escaped_args;
      30 | -    std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
      31 |      for (char* const* arg_ptr{argv}; *arg_ptr; ++arg_ptr) {
      32 | -        subprocess::util::quote_argument(converter.from_bytes(*arg_ptr), escaped_args.emplace_back(), false);
      33 | +        subprocess::util::quote_argument(fs::u8path(*arg_ptr).wstring(), escaped_args.emplace_back(), false);
    


    maflcko commented at 8:19 AM on July 13, 2026:

    nit: Could use named args here for the bool literal while touching?


    kevkevinpal commented at 3:16 PM on July 16, 2026:

    Yup, makes sense, and thank you for the review! Updated in abb2983

  5. hebasto commented at 8:26 AM on July 13, 2026: member

    Concept ACK.

  6. in src/common/system.cpp:56 in d8e64c1e85
      52 | @@ -53,7 +53,7 @@ void runCommand(const std::string& strCommand)
      53 |  #ifndef WIN32
      54 |      int nErr = ::system(strCommand.c_str());
      55 |  #else
      56 | -    int nErr = ::_wsystem(std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>,wchar_t>().from_bytes(strCommand).c_str());
      57 | +    int nErr = ::_wsystem(fs::u8path(strCommand).wstring().c_str());
    


    hebasto commented at 3:03 PM on July 14, 2026:

    This code was originally added to make runCommand handle UTF-8 command strings. Since #32380, the active code page is guaranteed to be UTF-8, so the narrow ::system() accepts UTF-8 directly and the wide conversion is no longer needed. Therefore, the correct solution here is to revert 23db9546c16c2be264cfc4f695f5738a2f5beeeb


    kevkevinpal commented at 3:15 PM on July 16, 2026:

    Thank you for the review. This should now be reverted in abb2983

  7. hebasto commented at 3:40 PM on July 14, 2026: member
  8. windows: replace deprecated codecvt with fs::u8path
    Remove std::wstring_convert/codecvt (deprecated in C++17, removed in
    C++26) in favor of fs::u8path().wstring() for UTF-8 to wide conversions.
    abb29836f5
  9. in src/util/exec.cpp:39 in d8e64c1e85
      37 |      new_argv.reserve(escaped_args.size() + 1);
      38 |      for (const auto& s : escaped_args) new_argv.push_back(s.c_str());
      39 |      new_argv.push_back(nullptr);
      40 | -    return _wexecvp(converter.from_bytes(file).c_str(), new_argv.data());
      41 | +    const std::wstring wfile{fs::u8path(file).wstring()};
      42 | +    return _wexecvp(wfile.c_str(), new_argv.data());
    


    hebasto commented at 4:03 PM on July 14, 2026:

    Given #32380, could we use a narrow execvp() here? Perhaps this will require templatizing subprocess::util::quote_argument.


    kevkevinpal commented at 3:15 PM on July 16, 2026:

    Thank you for the review, this should now be resolved in abb2983

  10. kevkevinpal force-pushed on Jul 16, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-07-22 01:50 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me