Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Inconsistent Interpretation of JSClass.name

15 views
Skip to first unread message

Masquerade

unread,
May 13, 2012, 8:20:09 AM5/13/12
to
This looks like a bug but I am not able to confirm it. I describe
what I saw here and let other experts to comment on it:

Currently, after defining JS_C_STRINGS_ARE_UTF8 or calling
JS_SetCStringsAreUTF8 (), strings (char* ) are considered as UTF8
encoded values. The JSClass.name is const char* type, and the way to
get a Unicode class name is probably by defining
JS_C_STRINGS_ARE_UTF8/ calling JS_SetCStringsAreUTF8 () and supply a
UTF8 enclosed value for the field. I've done some tests. This seems
to work and I am able to create my own classes having non-ASCII
Unicode names.

However, there are some standard functions interpreting this field as
plain ASCII only. and does not decode it as UTF8 string. For example,
standard Object.prototype.toString() implementation (obj_toString()
method in jsobj.cpp) interpret this Class.name field as plain ASCII
value and return it directly.

What should be the proper way to create a non-ASCII Unicode class
name? Should we make sure all standard functions interpret the
JSClass.name as UTF-8 string when JS_C_STRINGS_ARE_UTF8 is defined?

Masquerade

unread,
May 13, 2012, 8:20:14 AM5/13/12
to

Dave Mandelin

unread,
May 21, 2012, 3:42:54 PM5/21/12
to
Sounds like a bug, possibly fixed on trunk. I looked at obj_toStringHelper, and it calls StringBuffer::appendInflated on the class name. Are you using trunk (in which case it's a bug), or a source release?

Dave

Masquerade

unread,
May 27, 2012, 3:36:22 AM5/27/12
to
> Dave- Hide quoted text -
>
> - Show quoted text -

I am using the Spidermonkey source code from FF10 release.

Tom Schuster

unread,
May 27, 2012, 6:13:12 AM5/27/12
to Masquerade, dev-tech-js-en...@lists.mozilla.org
Yes I changed the code for that in
https://bugzilla.mozilla.org/show_bug.cgi?id=700169, which is tagged
mozilla-11, so only slightly missed the esr train. :(

But hey it's going to be fixed in the next esr version, for now you
could easily patch this manually. Just look at the patch in bug
700169.
> _______________________________________________
> dev-tech-js-engine-internals mailing list
> dev-tech-js-en...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals
0 new messages