12-18-2021 06:51 PM
When I try to unflatten an emoji from JSON I'm getting an error. I realize I'm not going to get the emoji out because LV doesn't support unicode yet but I believe the text is valid JSON so I don't think I should be getting a syntax error either.
Error -375003 occurred at Unflatten From JSON in parse emoji.vi
Possible reason(s):
LabVIEW: (Hex 0xFFFA4725) The JSON string is invalid. JSON strings must be encoded in UTF-8 and must conform to the JSON grammar.
=========================
12-19-2021 08:49 AM
😁
Emojis are UTF-16. Just ✔✅the HTML here.
12-19-2021 11:21 PM
Have you tried the JSONtext toolkit? That emits a "??" string in place of the emoji, but otherwise parses the JSON text correctly.
@JÞB wrote:
😁
Emojis are UTF-16. Just ✔✅the HTML here.
UTF-8 can handle emojis just fine. The HTML of this forum page is encoded as UTF-8.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
12-20-2021 02:20 AM
@JÞB wrote:
😁
Emojis are UTF-16. Just ✔✅the HTML here.
Any Unicode character can be represented in UTF-8, 16, and 32 and there are very simple mathematical translations to do so, although most choose to translate between UTF-8 and UTF-16 by going through UTF-32 in a tradeoff between speed and simplicity.
The emoji in the example is in proper UTF-8 but the current ANSI local doesn’t support it and LaBVIEW tries to convert the UTF-8 JSON string into an ANSI string and that fails. JSONText chooses to replace the “invalid” character with a placeholder (and seems to stumble over the fact that this is a 4 byte UTF-8 codepoint, representing it as two placeholders instead of one).
12-21-2021 01:01 PM - edited 12-21-2021 01:25 PM
I did some experimentation. It really seems to be a matter of the 4 byte code point that it's choking on. Here's it choking on a script A. Other code point, it just converts to a question mark which is preferred to throwing an error.