print UTF-8 file with BOM

Carsten Haese carsten at uniqsys.com
Fri Dec 23 10:00:56 EST 2005


> 2005/12/23, David Xiao <davihigh at gmail.com>:
>         Hi Kuan:
>         
>         Thanks a lot! One more question here: How to write if I want
>         to
>         specify locale other than current locale?
>         
>         For example, running on Korea locale system, and try read a
>         UTF-8 file
>         that save chinese. 

Use the encode method to translate the unicode object into whatever
encoding you want.

unicodeStr = ...
print unicodeStr.encode('big5')

Hope this helps,

Carsten.





More information about the Python-list mailing list