How to work with UTF-16¶
Example on how to work with UTF-16 strings
We have this json, which includes UTF-16 characters:¶
{
"game_title": "H\u03bblf Life 3",
"description": "\"There's no such thing as H\u03bblf-Life 3\" By this point in the story you won't be too surprised to read the words ...",
"price": 4999,
"id": 23032020
}
Getting the u16strings (C++):¶
Json json;
json.Parse(aboveJsonCode);
std::string rawTitle = json.AsJson.Get("game_title").AsString;
std::string rawDescr = json.AsJson.Get("description").AsString;
std::u16string gameTitle = UTF16Compatibility::ParseUTF16(rawTitle);
std::u16string gameDescr = UTF16Compatibility::ParseUTF16(rawDescr);
Putting the u16strings back in (C++):¶
json.AsJson.Get("game_title") .SetStringData(UTF16Compatibility::EscapeUTF16(gameTitle));
json.AsJson.Get("description").SetStringData(UTF16Compatibility::EscapeUTF16(gameDescr));
That's it.