I'm trying to figure out how to get utf16 characters in my json string. This is my json:
ourWideStringClass jsonNoError("{ \
\"type\" : \"ROI\", \
\"m_position\" : { \
\"m_x\" : 16, \
\"m_y\" : 32, \
\"m_z\" : 0 \
}, \
\"m_size\" : { \
\"m_width\" : 64, \
\"m_height\" : 128, \
\"m_depth\" : 3 \
} \
} ");
So if I have the following utf16, I'm not sure how to put that in the above. I know I can't put 0x9CE5 in the json, like by replacing 128 with 0x9CE5. I'm not sure what to do. Any ideas?
I was reading encoding U . I'm not sure if I can use the escape U in my json string or how to do that. Would it be \\U"m_x" ?
If you need to have the U+9CE5
character as a part of a string within JSON, you can do so by encoding it as \鳥
, eg:
"key": "before\u9ce5after"
Alternatively, you can include this character unencoded in your JSON .
Please refer to json.org for JSON syntax, eg:
"key": "before鳥after"
Please note that the term "UTF-16 character" is not correct. UTF-16 doesn't define any characters — it's a specification how to encode Unicode characters . The characters themselves (or codepoints) are defined by the Unicode standard, and a whole string of Unicode characters may be encoded as UTF-16, UTF-8 or via other encoding schemes.
So all of your JSON is in some encoding (eg in UTF-16), not just separate characters.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.