I am writing a JSON parser in C ++ and am encountering a problem while parsing JSON strings:
The JSON specification states that JSON strings can contain Unicode characters in the form:
"here comes a unicode character: \u05d9 !"
My JSON parser is trying to match JSON strings with std::string , as usual, one character of JSON strings becomes one character of std::string . However, for these Unicode characters, I really don't know what to do:
Should I just put the raw byte values ββin my std::string like this:
std::string mystr; mystr.push_back('\0x05'); mystr.push_back('\0xd9');
Or should I interpret the two characters with a library like iconv and instead store the UTF-8 result in my encoding instead?
Should I use std::wstring to store all characters? So what on * NIX OS, where wchar_t is 4 bytes long?
I feel that something is wrong with my decisions, but I do not understand that. What should I do in this situation?
source share