After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 778729 - Console output of arrays should be UTF-8 aware
Console output of arrays should be UTF-8 aware
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
1.47.x
Other Linux
: Normal normal
: ---
Assigned To: Philip Chimento
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2017-02-16 01:21 UTC by Philip Chimento
Modified: 2017-02-26 21:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
jsapi-util: Debug value should not use JS_EncodeStringToBuffer() (2.88 KB, patch)
2017-02-25 22:42 UTC, Philip Chimento
committed Details | Review

Description Philip Chimento 2017-02-16 01:21:11 UTC
Output from gjs-console:

    gjs> Array.from('
Comment 1 Philip Chimento 2017-02-16 01:22:35 UTC
Wow, Bugzilla does not like UTF-8 either apparently.

http://pastebin.com/nLbQDK44
Comment 2 Philip Chimento 2017-02-18 01:57:16 UTC
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.
Comment 3 Philip Chimento 2017-02-25 22:05:47 UTC
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
Comment 4 Philip Chimento 2017-02-25 22:42:40 UTC
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().
Comment 5 Cosimo Cecchi 2017-02-26 02:40:39 UTC
Review of attachment 346723 [details] [review]:

Looks good.
Comment 6 Philip Chimento 2017-02-26 21:53:40 UTC
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.
Comment 7 Philip Chimento 2017-02-26 21:54:50 UTC
Attachment 346723 [details] pushed as 771d8ec - jsapi-util: Debug value should not use JS_EncodeStringToBuffer()