John Machin wrote:
> On 16 May 2005 16:44:30 -0700, [EMAIL PROTECTED] wrote:
[snip]
>
>
> Like I said, *ALL* you have to do (like in any other Unicode-aware
> app) is decode your user input into Unicode (you *don't* need to
parse
> bits and pieces of it) and feed it in ... like this:
>
> >>> user_input_kr = "inside=u'\xc7\xd1\xb1\xdb'"
> >>> user_input_uc = user_input_kr.decode('euc-kr')
> >>> user_input_uc
> u"inside=u'\ud55c\uae00'"
> >>> s = compile(user_input_uc, '', 'single')
> >>> exec s
> >>> inside
> u'\ud55c\uae00'
> >>> # right
>
> HTH,
> John

Thank you but there is still a problem.

|>>> s='euckr="\xc7\xd1";uni=u"\xc7\xd1"'
|>>> su=s.decode('euc-kr')
|>>> su
|u'euckr="\ud55c";uni=u"\ud55c"'
|>>> c=compile(su,'','single')
|>>> exec c
|>>> euckr,uni
|('\xed\x95\x9c', u'\ud55c')
|>>>

As you see the single's result is turned into UTF-8 encoding.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to