how to convert string like '\u5927' to unicode string u'\u5927'
Ganesan Rajagopal
rganesan at myrealbox.com
Tue Dec 27 06:07:23 EST 2005
More information about the Python-list mailing list
Tue Dec 27 06:07:23 EST 2005
- Previous message (by thread): [EVALUATION] - E04 - Leadership! Google, Guido van Rossum, PSF
- Next message (by thread): how to convert string like '\u5927' to unicode string u'\u5927'
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
>>>>> "Chris" == Chris Song <fakechris at gmail.com> writes: > Here's my solution > _unicodeRe = re.compile("(\\\u[\da-f]{4})") > def unisub(mo): > return unichr(int(mo.group(1)[2:],16)) > unicodeStrFromNetwork = '\u5927' > unicodeStrNative = _unicodeRe(unisub, unicodeStrFromNetwork) How about unicodeStrNative = eval("u'%s'" % (unicodeStrFromNetwork,)) Ganesan -- Ganesan Rajagopal (rganesan at debian.org) | GPG Key: 1024D/5D8C12EA Web: http://employees.org/~rganesan | http://rganesan.blogspot.com
- Previous message (by thread): [EVALUATION] - E04 - Leadership! Google, Guido van Rossum, PSF
- Next message (by thread): how to convert string like '\u5927' to unicode string u'\u5927'
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list