Skip to content
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

Fix Windows encoding issue #1054

Closed
wants to merge 1 commit into from
Closed

Conversation

bschatt
Copy link

@bschatt bschatt commented Jun 12, 2024

We uses CLI11 internally to build some of our tools. We are building with MSVC from VS2022, have enabled UNICODE on Windows, as suggested in the UTF-8 Everywhere manifesto and codecvt is available (CLI11_HAS_CODECVT is 1). With this setup we have been unable to parse non-ANSI parameters properly.

We have tracked the issue back to the narrow implementation. Specifically on Windows, codecvt_utf8_utf16 is used to convert str. Even though the type is wchar_t it is NOT an UTF-16 string. It's actually an UCS-2 string.

return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>().to_bytes(str, str + str_size);

According to the documentation, codecvt_utf8<wchar_t> convert UTF-8 to/from UCS-2 on Windows and to/from UTF-32 on other platforms.
image

This probably fixes #1042

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

widen convert faild in Windows
1 participant