ironm73 / pyv8

Automatically exported from code.google.com/p/pyv8
0 stars 0 forks source link

unicode? #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
hi~
the result of program:
None
None

False
True

the code in qval() is encoding with utf-8 or not?

Original issue reported on code.google.com by fabienow...@gmail.com on 21 Apr 2009 at 9:22

Attachments:

GoogleCodeExporter commented 8 years ago
sure, it doesn't consider the unicode issue, and use ascii encoding by default, 
I will fix 
it soon, thanks :)

Original comment by flier...@gmail.com on 22 Apr 2009 at 4:45

GoogleCodeExporter commented 8 years ago
I have added some convert code which support the bi-way automatic conversion 
with UTF-8 encoding

    def testUnicode(self):
        with JSContext() as ctxt:
            self.assertEquals(u"人", unicode(ctxt.eval("\"人\""), "utf-8"))
            self.assertEquals(u"é", unicode(ctxt.eval("\"é\""), "utf-8"))

            func = ctxt.eval("function (msg) { return msg.length; }")

            self.assertEquals(2, func(u"测试"))

please check the change list for more detail, thanks :)
http://code.google.com/p/pyv8/source/detail?r=119

Original comment by flier...@gmail.com on 22 Apr 2009 at 9:18