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

2005-12-27 Thread Ganesan Rajagopal
> "Fredrik" == Fredrik Lundh <[EMAIL PROTECTED]> writes: > Ganesan Rajagopal wrote: >>> unicodeStrFromNetwork = '\u5927' >>> unicodeStrNative = _unicodeRe(unisub, unicodeStrFromNetwork) >> >> How about unicodeStrNative = eval("u'%s'" % (unicodeStrFromNetwork,)) > unicodeStrFromNetwork = "' +

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

2005-12-27 Thread Fredrik Lundh
Ganesan Rajagopal wrote: >> unicodeStrFromNetwork = '\u5927' >> unicodeStrNative = _unicodeRe(unisub, unicodeStrFromNetwork) > > How about unicodeStrNative = eval("u'%s'" % (unicodeStrFromNetwork,)) unicodeStrFromNetwork = "' + str(__import__('os').system('really bad idea')) + '" -- http:

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

2005-12-27 Thread Ganesan Rajagopal
> "Chris" == Chris Song <[EMAIL PROTECTED]> 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

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

2005-12-27 Thread Leif K-Brooks
Chris Song wrote: > 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) > > But I think there must be a more straigh

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

2005-12-27 Thread Chris Song
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) But I think there must be a more straightforward way to do it. -- http://m

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

2005-12-27 Thread Chris Song
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) But I think there must be a more straightforward way to do it. -- http://m