Last active
May 28, 2025 03:28
-
-
Save leongkui/bfa7cd53a55bff83503d5d1cbdd193be to your computer and use it in GitHub Desktop.
Fix/convert GBK/GB2312 format to UTF8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import codecs | |
import sys | |
# https://stackoverflow.com/questions/53954604/python-encoding-chinese-to-special-character | |
infile = codecs.open(sys.argv[1], "r", "gb2312") | |
lines = infile.readline() | |
infile.close() | |
print(lines) | |
outfile = codecs.open("out.txt", "wb", "utf-8") | |
outfile.writelines(lines) | |
outfile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment