Movatterモバイル変換
[0]ホーム
Jython: How to import escaped Unicode and export utf-8?
Maurice Bauhahnbauhahnm at clara.net
Sun Apr 29 15:27:49 EDT 2001
My problem is importing such escapes from a file. Can you do that? I note also thatyou are using version 2.0 which is not documented to have the two hex characterlimitation.Cheers,MauriceFredrik Lundh wrote:> Maurice Bauhahn wrote:> > Hence, it appears that not only is it not possible to import \uXXXX, it is also> > appears impossible to handle any Unicode escape above the first 256> > characters...effectively ignoring Unicode altogether??? Is there something I am> > missing?>> from the python documentation:>> \uxxxx - Character with 16-bit hex value xxxx (Unicode only)> \Uxxxxxxxx - Character with 32-bit hex value xxxxxxxx (Unicode only)> \xhh - ASCII character with hex value hh>> in my copy of jython, given a sample.py file containing>> a = u"\u1780">> on a single line, I get:>> Jython 2.0 on java1.1.4> >>> execfile("sample.py")> >>> a> u'\u1780'> >>> len(a)> 1> >>> a.encode("utf-8")> '\341\236\200'> >>> u"\u1780".encode("utf-8")> '\341\236\200'>> which is exactly what it's supposed to be (and exactly> what CPython 2.0 does)>> Cheers /F--Maurice Bauhahn2 Meadow WayDorney ReachMAIDENHEADSL6 0DSUnited KingdomHome Tel: +44(0)1628 626068Work Tel: +44(0)1932 878404Home Email:bauhahnm at clara.netWork Email:mbauhahn at brio.com
More information about the Python-listmailing list
[8]ページ先頭