Skip to content
UTF16Compatibility

ParseUTF16

static std::u16string ParseUTF16(const std::string str)

Kind of like U8_2_U16(), except that it will also unescape character sequences, like, for example \u03c0.

Any invalid UTF escape sequence, for example:

  • \u03ge Not valid hex
  • \u0 Not 4 places long
  • \u No hex values at all

will raise a JsonParsingUTFSequenceException!.


Examples:

C++:
UTF16Compatibility::ParseUTF16("H\\u03bblf Life 3");
Returns string:

Hλlf Life 3


C++:
UTF16Compatibility::ParseUTF16("Life of \\u03c0");
Returns string:

Life of π