how to write text into file in ansi encoding ?

James Yu cyu021 at gmail.com
Thu Feb 21 02:27:35 EST 2008


I just figure out the how-to:
# first we open and read in chars as in utf-8 encoding
ansiLine = line.decode('utf-8', 'ignore')
# then writing it into another file in any encoding you like, it's big5 in
my case.
src_handle.write(ansiLine.encode('big5', 'ignore'))

-- 
This is a UTF-8 formatted mail
-----------------------------------------------
James C.-C.Yu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080221/d9cd2ae1/attachment-0001.html>


More information about the Python-list mailing list