Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect unicode conversion between python object and javascript object on FreeBSD #9

Closed
GoogleCodeExporter opened this issue Dec 2, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

I compiled PyV8 under freebsd, and got following error:

with JSContext() as c:
    c.locals.s = u"测试"
    print len(c.locals.s)    # this will print 1, instead of 2

    c.locals.s = u"1234"
    print len(c.locals.s)    # this will print 1, instead of 4

In fact assign an unicode to JSContext will always return its length as 1.

After dig into the code, I found this is caused because on my FreeBSD the
python unicode is defined as UCS4 - the wide unicode (on win32, it will be
UCS2) this caused a problem when converting python unicode to v8::String in
CPythonObject::Wrap() method.

I patched the method to check if python is using UCS4 or UCS2 to determine
how to convert python unicode to v8::String.

Attached is the patched Wrapper.cpp, line 458-470 is modified.

Original issue reported on code.google.com by nuphahu...@gmail.com on 30 Sep 2009 at 5:18

Attachments:

@GoogleCodeExporter
Copy link
Author

Thanks for your contribute, please check out the changes after SVN r159

Original comment by flier...@gmail.com on 8 Oct 2009 at 4:29

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

Issue 7 has been merged into this issue.

Original comment by flier...@gmail.com on 8 Oct 2009 at 4:30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant