print UTF-8 file with BOM

Carsten Haese carsten at
Fri Dec 23 16:00:56 CET 2005

> 2005/12/23, David Xiao <davihigh at>:
>         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,


More information about the Python-list mailing list