#28 ✓resolved
Frank Bennett

Locale setting?

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

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

Comments and changes to this ticket

  • Paul J. Davis

    Paul J. Davis July 28th, 2009 @ 10:55 PM

    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:

  • Frank Bennett

    Frank Bennett July 28th, 2009 @ 11:23 PM

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

  • Frank Bennett

    Frank Bennett August 18th, 2009 @ 06:21 PM

    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.

  • Paul J. Davis

    Paul J. Davis August 18th, 2009 @ 06:30 PM

    • Tag set to conversion, unicode
    • State changed from “new” to “resolved”

    Frank,

    Good news. Thanks for reporting back.

    Paul

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Python/JavaScript bridge module, making use of Mozilla's spidermonkey JavaScript implementation. Allows implementation of JavaScript classes, objects and functions in Python, and evaluation and calling of JavaScript scripts and functions respectively. Borrows heavily from Claes Jacobssen's Javascript Perl module, in turn based on Mozilla's 'PerlConnect' Perl binding.

People watching this ticket

Attachments

Pages