-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<filesystem>
: MSVC's path
conversion from wide to narrow throws an exception (fs::path(L"要").string()
)
#5093
Comments
fs::path(L"要").string()
)
The error code seems to be the following.
The exception can be avoided when the source file is encoded in UTF-8 and the program is compiled with |
Works fine for me on my "Beta: Use UTF-8 for language support" machine, and the same for Compiler Explorer (https://www.godbolt.org/z/oGMbo3YE1). The problem is most likely:
|
Yes, that I already did and could still reproduce. Try disabling the beta feature in your Region system settings and then restart your computer. You'll be able to reproduce. I tried with both, where the file is UTF8 encoded with and without BOM. Also of course the |
Of course that works, but that's unfortunately not a solution I can instruct the consumers of my application to use. Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Nls\CodePage' -Name 'ACP' -Value '65001'
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Nls\CodePage' -Name 'OEMCP' -Value '65001'
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Nls\CodePage' -Name 'MACCP' -Value '65001' Here he talks further about some of the changes they made: https://xania.org/202407/msvc-on-ce |
I'm not sure there's a bug here. If the library is throwing |
We talked about this at the weekly maintainer meeting - I agree with Casey that this sounds by design but we need more info. The filesystem codepage, the source character set (which is a non-issue if you use universal-character-names for your repro), and the execution character set (the last two are controlled by |
fs::path(L"要").string()
)<filesystem>
: MSVC's path
conversion from wide to narrow throws an exception (fs::path(L"要").string()
)
Describe the bug
MSVC's std::filesystem::path conversion from wide to narrows crashing with the following snippet:
I also tried in a fresh sandbox with fresh latest VS Community installation and crash is happening on both builds x86|x64 Debug|Release:
Microsoft C++ exception: std::system_error at memory location
Also tried compiling with and without unicode enabled. Same behavior.
Expected behavior
conversion should succeed and not crash the program.
STL version
Microsoft Visual Studio Community 2022 (64-bit) - Current
Version 17.11.1
The text was updated successfully, but these errors were encountered: