On 5月30日, 下午9时03分, Tijs <[EMAIL PROTECTED]> wrote: > ??????????????? wrote: > > But the string contained the u'\u20ac' is get from remote host. Is > > there any method to decode it to the local 'mbcs'? > > remote_string = u'\u20ac' > try: > local_string = remote_string.encode('mbcs') > except: > # no mbcs equivalent available > print "encoding error" > else: > # local_string is now an 8-bit string > print "result:", local_string > # if console is not mbcs, you should see incorrect result > assert result == '\x80' > > Mbcs is windows-only so I couldn't test this. > > If your application handles text, it may be easier to just leave everything > in Unicode and encode to utf-8 for storage? > > Regards, > Tijs
Yes, it works, thank you. But I doubt this way may not work on linux. Maybe I should write some additional code for supporting both windows and linux OS.
-- http://mail.python.org/mailman/listinfo/python-list