Skip to content

Commit

Permalink
Fix convert bug
Browse files Browse the repository at this point in the history
  • Loading branch information
alanshi committed Jan 31, 2024
1 parent 5a0f851 commit 2eeb415
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions convert_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,9 @@ def convert_file_to_utf8(file):
read_data = f_in.read()

with open(file_path, "w", encoding="utf-8") as f_out:
flag, out_data = api.decode_check(read_data, encoding)
if flag:
out_data = api.decode(read_data, encoding)
if out_data:
f_out.write(out_data)
else:
msg = f"{file_path} {encoding} 转换到utf8失败, {out_data}"
os.remove(file_path)
return False, msg

except Exception as e:
msg = f"{file_path} {encoding} 转换到utf8失败, {e}"
Expand Down

0 comments on commit 2eeb415

Please sign in to comment.