jsonEncode and jsonDecode issue with special characters

Hi, is there a limitation on the supported characters for json encoding ? When running this code

tagsArray = []
tagsArray.append(["bébé"])
TagsAsJSON = system.util.jsonEncode(tagsArray)
tagsArray = system.util.jsonDecode(TagsAsJSON)
tagsDS = system.dataset.toDataSet(["Test"],tagsArray)

print tagsDS.getValueAt(0,0)

I get “bébé” instead of “bébé”

No. This is probably a character encoding issue. Try using a Python Unicode string instead of a byte string:

Use this:

tagsArray.append([u"bébé"])

Instead of this:

tagsArray.append(["bébé"])

Using

tagsArray.append([u"bébé"])

I get “bébé” instead of “bébé”

Okay, what version of Ignition are you using? Are you using Windows or Linux?

I use 7.6.4 (b2013112117) on Windows

Instead of printing out the result, can you display it in a message box? I have a feeling you’re now running in to a display bug in the Windows console that’s been fixed for 7.6.6.

Hi,

I get the same string in a messagebox.

Also, I just saw this in the 7.6.5.2014031012-rc4 release notes :

Fixed - The scipting function system.util.jsonEncode now encodes Unicode characters.

Ah, well that would explain it. :slight_smile:

I do apologize for the issues you’ve had with non-English characters. We’ve been working hard on getting all of these tracked down and squashed. AFAIK, 7.6.5 will only have a couple Windows-specific issues (printing to the console and error messages in the GCU), which have been fixed for 7.6.6.