how to convert string like '\u5927' to unicode string u'\u5927'

Ganesan Rajagopal rganesan at myrealbox.com
Tue Dec 27 06:40:11 EST 2005


>>>>> "Fredrik" == Fredrik Lundh <fredrik at pythonware.com> writes:

> Ganesan Rajagopal wrote:
>>> unicodeStrFromNetwork = '\u5927'
>>> unicodeStrNative = _unicodeRe(unisub, unicodeStrFromNetwork)
>> 
>> How about unicodeStrNative = eval("u'%s'" % (unicodeStrFromNetwork,))

> unicodeStrFromNetwork = "' + str(__import__('os').system('really bad idea')) + '"

Thanks for the warning. I should really know better! *blush* 

Ganesan

-- 
Ganesan Rajagopal (rganesan at debian.org) | GPG Key: 1024D/5D8C12EA
Web: http://employees.org/~rganesan        | http://rganesan.blogspot.com





More information about the Python-list mailing list