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

widen convert faild in Windows #1042

Open
TianZerL opened this issue May 18, 2024 · 3 comments
Open

widen convert faild in Windows #1042

TianZerL opened this issue May 18, 2024 · 3 comments

Comments

@TianZerL
Copy link

If the input filename is unicode(at least with Chinese) and use CLI::ExistingFile to check it, which will call widen_impl indirectly, the line return std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>().from_bytes(str, str + str_size); failed in Windows.

PS D:\temp\ac> .\ac_cli.exe '.\read - 副本.jpg'
terminate called after throwing an instance of 'std::range_error'
  what():  wstring_convert::from_bytes

I'm using Windows 11 and C++17 standard, and this happend in both VS2022 and MinGW64 gcc 14.1.0.

if I disable CLI11_HAS_CODECVT, the std::mbsrtowcs will fail too.

@phlptp
Copy link
Collaborator

phlptp commented May 20, 2024

Any possibility you could write a failing test in the test cases and add in a PR?

@TianZerL
Copy link
Author

TianZerL commented May 21, 2024

@phlptp
I think I found the problem. In the Chinese version of Windows, the default encoding for the terminal is GBK (page 936), while CLI11 uses it as utf8, so the convert failed.

Does CLI11 have plans to support local 8-bit encoding?

@henryiii
Copy link
Collaborator

If someone knows how to fix it, we could. Don't use Windows or local encodings, or know how to test local encodings in CI.

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 a pull request may close this issue.

3 participants