Shift-JIS to UTF-8 conversion
Jeff Epler
jepler at unpythonic.net
Thu May 19 19:10:20 EDT 2005
I think you do something like this (untested):
import codecs
def transcode(infile, outfile, incoding="shift-jis",
outcoding="utf-8"):
f = codecs.open(infile, "rb", incoding)
g = codecs.open(outfile, "wb", outcoding)
g.write(f.read())
# If the file is so large that it can't be read at once, do a loop which
# reads and writes smaller chunks
# while 1:
# block = f.read(4096000)
# if not block: break
# g.write(block)
f.close()
g.close()
Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050519/6c2e9017/attachment.sig>
More information about the Python-list
mailing list