convert gb18030 to utf16

A

and-google

Xah Lee said:
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()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top