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
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
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--006a51241073e994b41acfe9ec718e94-->
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35704.
<!--021abf342d371248e50ceaed478a90ca-->
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><!--meta-tag:bot-skip--></code> into the comment that the bot should ignore.
<!--174a7506f384e20aa4161008e828411d-->
Reviewers, this pull request conflicts with the following ones:
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-->
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);
nit: Could use named args here for the bool literal while touching?
Yup, makes sense, and thank you for the review! Updated in abb2983
Concept ACK.
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());
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
Thank you for the review. This should now be reverted in abb2983
cc @ryanofsky
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.
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());
Thank you for the review, this should now be resolved in abb2983