GNOME Bugzilla – Bug 778729
Console output of arrays should be UTF-8 aware
Last modified: 2017-02-26 21:54:54 UTC
Output from gjs-console: gjs> Array.from('
Wow, Bugzilla does not like UTF-8 either apparently. http://pastebin.com/nLbQDK44
This seems to be specific to printing out arrays on the console. If you just enter the string with Unicode desserts with quotes around it at the gjs> prompt, it prints out OK.
I filed this upstream [1], but I'll try to work around it for now in GJS. [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1342703
Created attachment 346723 [details] [review] jsapi-util: Debug value should not use JS_EncodeStringToBuffer() JS_EncodeStringToBuffer() does not encode to UTF-8, so if an object's toString() method returns any non-ASCII codepoints, they will get mangled. Instead use JS_EncodeStringToUTF8().
Review of attachment 346723 [details] [review]: Looks good.
According to the responses on the Mozilla bug, the documentation of JS_EncodeStringToBuffer() was incorrect. They added some new documentation for JS::DeflateStringToUTF8Buffer() which replaces it, and which I wasn't aware of before, but I think JS_EncodeStringToUTF8() is fine for this use case.
Attachment 346723 [details] pushed as 771d8ec - jsapi-util: Debug value should not use JS_EncodeStringToBuffer()