3 ms·
The need to convert UTF-8 <-> UTF-16 is not going to go away anytime soon. Many existing formats or APIs specify one or the other.
by int_19h 4y ago
The need to convert UTF-8 <-> UTF-16 is not going to go away anytime soon. Many existing formats or APIs specify one or the other.
- mlindner 4y agoThere are only two types of APIs, those that support UTF-8 and broken APIs. Users should actively file bug reports with any system or product that insists on UTF-16 or abandon use of such legacy systems if they refuse to change.
- flohofwoe 4y agoUTF-16 is only a pain when working with Windows APIs though. Most other 'legacy APIs' I've seen so far provide easy ways to get UTF-8 encoded data in and out, even though they use UTF-16 under the hood (like [NSString stringWithUTF8String:] on macOS).
- int_19h 4y agoWin32 also has MultiByteToWideChar and friends, although being a C API, it's not particularly pleasant to use. For newer HSTRING-based WinRT APIs, if you're calling them from C++, you're probably going to use C++/WinRT, which provides conversion functions that operate on std::string_view and std::wstring_view. So, you're right, I need to amend that to "mostly needed for file formats and protocols".