1

I think string can handle ANSI and wstring can handle Unicode16, is that right?

does C++ STL has class which can support UTF8 strings?

Adam Lee
  • 23,314
  • 47
  • 144
  • 221

1 Answers1

3

Just use std::string. It handles UTF-8 strings just fine.

Obviously you need to be aware that a codepoint can be 1 to 4 chars, and that a character can actually be any number of codepoints, but that rarely matters to you, and when it matters, std::wstring would have the same problems.

Big advantage is that std::string works the same everywhere. With std::wstring, different implementations use 16 bit or 32 bit numbers with very different meanings, there are problems with byte ordering and so on.

gnasher729
  • 49,784
  • 5
  • 72
  • 94
  • The various collate functions should produce different results on occasion because they assume different encodings and code points. – jww Jan 04 '15 at 09:27