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

How about std::wstring? #2

Open
z16166 opened this issue Jul 30, 2023 · 2 comments
Open

How about std::wstring? #2

z16166 opened this issue Jul 30, 2023 · 2 comments

Comments

@z16166
Copy link

z16166 commented Jul 30, 2023

Your lib is quite elegant.

Usually I use std::wstring in memory to support case-insensitive comparison/search. UTF8 string is not good for such scenarios.

Would you please add std::wstring support? We usually use Windows API to convert between UTF8/wchar_t for Windows, and use libiconv for Linux/macOS. Thanks.

@jake-stewart
Copy link
Owner

i have never worked with std::wstring.

a quick search found this approach for converting to/from utf8/wchar_t:

#include <locale>
#include <codecvt>
#include <string>

std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
std::string narrow = converter.to_bytes(wide_utf16_source_string);
std::wstring wide = converter.from_bytes(narrow_utf8_source_string);

https://stackoverflow.com/questions/2573834/c-convert-string-or-char-to-wstring-or-wchar-t

would there be any downsides using this approach over Windows API and libiconv?

@z16166
Copy link
Author

z16166 commented Aug 5, 2023

C++ codecvt is deprecated. Anyway it still can be compiled and convenient, compared to libiconv、ICU.

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

No branches or pull requests

2 participants