1

C++11 introduced ways to perform conversion between raw byte-strings, represented by std::string, and unicode strings, like std::u32string.

However, looking at the page on cppreference, I see that the whole thing gets deprecated in C++17 (namely, std::wstring_convert and everything from the <codecvt> header).

My attempts at finding a C++17-way to do the conversion failed: there seems to be no replacement, just deprecation of functionality.

So, my question is: what is the correct standard way to perform the aforementioned conversion in C++17, and does it exist at all?

lisyarus
  • 15,025
  • 3
  • 43
  • 68
  • wstring_convert is correct and standard. It was deprecated out of wishful thinking, like strstream – Cubbi Sep 21 '17 at 13:06
  • 1
    see also https://stackoverflow.com/questions/42946335 – Cubbi Sep 21 '17 at 13:17
  • Deprecated does not mean "not available". It means "to eventually be removed". So using it remains valid, and it will be valid until there is a replacement – Nicol Bolas Sep 21 '17 at 14:59
  • @Cubbi: "*It was deprecated out of wishful thinking, like strstream*" Both this stuff and `strstream` are on the chopping block, since replacements for them have been proposed (`strstream` being replaced by a `span`-based stream). So it's hardly "wishful thinking". – Nicol Bolas Sep 21 '17 at 15:01
  • @NicolBolas sure, p407+p408+p448. So in 2020, there's a chance that the promised replacement to something deprecated in 1998 might arrive. Here's hoping for new Unicode conversions by 2035. – Cubbi Sep 21 '17 at 15:20
  • @Cubbi: Or, it could be in 2020. Or did you miss [P0244](http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2017/p0244r2.html)? – Nicol Bolas Sep 21 '17 at 15:53

0 Answers0