Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Locale setting?

#28

I'm working on a JS application that does intensive string parsing (for the formatting of bibliography entries). I have a set of 200+ test fixtures that currently run under Rhino. I've built a test runner for the fixtures using varmaa's python-spidermonkey implementation (from Google Code), which fails on data containing Cyrillic or Chinese characters.

We had a similar issue under Rhino on the Mac, which we traced to a discrepancy in the internal locale settings applied in the JS interpreter -- we need UTF-8, but the Mac Rhino was ignoring the shell setting and assuming "macroman".

I've been unable to find a means of setting the locale explicitly in varmaa's python-spidermonkey. Before I gear up to try the latest code, I have two questions:

(1) Am I just missing something? (2) Has something for locale support been added to python-spidermonkey since 2008?

(Sorry for using the tracker for this support matter. I didn't spot any other way of getting in touch.)

Many thanks,
Frank Bennett

Reported by Frank Bennett · July 28th, 2009 @ 07:49 PM

State: resolved
Milestone: none
Assigned to: Paul J. Davis Paul J. Davis

Activity

  1. Paul J. Davis
    Paul J. Davis

    I'll have too look but I would guess that if you can get the locale
    set in python it should work as I'm just using the builtin unicode
    conversions.

    My version on github was originally a derivative of Atul's but has
    moved slot since then. You might just try it and see what happens. The
    API is fairly close but not 100% compatible.

    On Jul 28, 2009, at 7:49 PM, Lighthouse no-reply@lighthouseapp.com
    wrote:

    July 28th, 2009 @ 10:55 PM

  2. Frank Bennett
    Frank Bennett

    Thanks! I'll do an install sometime soon and report back on how we fare.

    July 28th, 2009 @ 11:23 PM

  3. Frank Bennett
    Frank Bennett

    Paul,

    Sorry for the long delay in responding. This morning I finally took the time to distill the problem down to a simple test script, and installed your version Just as you suspected, it works fine.

    The previous edition of python-spidermonkey would fail when above-ascii unicode chars were passed via the eval_script method on the context object. With your version, they are digested without a hitch. In fact, when the python interpreter is run with UTF-8 as the default encoding, cx.execute is indifferent to whether the string on the python side of the bridge is in Unicode or UTF-8; everything gets correctly converted to Unicode within JS. Absolutely splendid.

    The quickie script that I used for testing is attached.

    August 18th, 2009 @ 06:21 PM

  4. Paul J. Davis
    Paul J. Davis
    • Tag set to conversion, unicode
    • State changed from new to resolved

    Frank,

    Good news. Thanks for reporting back.

    Paul

    August 18th, 2009 @ 06:30 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.