convert gb18030 to utf16
and-google at doxdesk.com
and-google at doxdesk.com
Sun Mar 6 03:27:27 EST 2005
Xah Lee <xah at xahlee.org> wrotE:
> i have a bunch of files encoded in GB18030. Is there a way to convert
> them to utf16 with python?
You will need CJKCodecs (http://cjkpython.i18n.org/), or Python 2.4,
which has them built in. Then just use them like any other codec. eg.
f= open(path, 'rb')
content= unicode(f.read(), 'gb18030')
f.close()
f= open(path, 'wb')
f.write(content.encode('utf-16'))
f.close()
--
Andrew Clover
mailto:and at doxdesk.com
http://www.doxdesk.com/
More information about the Python-list
mailing list