UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcc in position 134: invalid continuation byte
UnicodeEncodeError: 'charmap' codec can't encode character '\ufeff' in position 0: character maps to
UnicodeEncodeError: 'charmap' codec can't encode character '\xef' in position 0: character maps to
import codecs
import os
path = os.getcwd() + "\\files\\"
path_out = os.getcwd() + "\\files\\result_files\\"
print(path)
print(path_out)
array = []
def primary():
for filename in os.listdir(path):
print(filename)
#read input file
with codecs.open(path+filename, 'r', encoding="ISO-8859-1") as file:
lines = file.read()
try:
#write output file
with codecs.open(path_out+filename, 'w', encoding = 'cp1251') as file:
file.write(lines)
except FileNotFoundError:
print("[ERROR] No file created")
if __name__ == '__main__':
primary()
https://dropmefiles.com/cqGSg
if __name__ == '__main__':
with open('acda010.ditamap', encoding='utf-8-sig') as file:
cc = ''.join(file.readlines())
with open('a.txt', 'w', encoding='cp1251') as file:
print(cc, end='', file=file)