I have a bunch of txt files that is encoded in shift_jis, I want to convert them to utf-8 encoding so the special characters can display properly. This has been probably asked before, but I can't seem to get it right.
Update: I changed my code so it first write to a list then it will write the content from the list.
words = []
with codecs.open("dummy.txt", mode='r+', encoding='shiftjis') as file:
words = file.read()
file.seek(0)
for line in words:
file.write(line.encode('utf-8'))
However now I get runtime error, the program just crashes. Upon further investigation, it seems like the "file.seek(0)" has caused the program to crash. The program runs without error if this line is commented. I don't know why it is so. How is it causing errors?