converting from string to u8string

Is there a standard way (ie. apart from using something like WideCharToMultiByte()) to convert between string, wstring, and unicode strings? <cstdlib>, <cwchar>, and <cuchar> have a number of functions that seem like they might be designed for that purpose, but don't explicitly say it, so I'm unsure as to exactly what they are converting to/from.
That post was an interesting starting point, but in the end proved fruitless. Either they are using the Windows API functions (ie. WideCharToMultiByte(), etc...), or they suggest using codecvt.

codecvt is interesting in that it seems it was intended to do this conversion, and does successfully in VS2019, but is supposed to be deprecated in C++20 (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0618r0). No mention of a replacement.

So I'm rather confused at this point as to what the 'official' way to convert between string, wstring, and the unicode strings is supposed to be. I've written utf8, utf16, and utf32 conversion routines, this is easy as their encoding doesn't depend on local information. But string and wstring do depend on local encoding and can/do change significantly depending on compiler/platform...

Any ideas?
I think the answer is going to be to find a pro library that does this. I don't think c++ has what you need directly.

I don't know what the go-to lib for this would be.
Last edited on
Topic archived. No new replies allowed.