[回复]
[修改] [删除]
[返回版面]
|
1 |
作者: admin, 讨论版: 本站建设, 发表时间: 2022-11-27 16:08:33 PST
标题: Fix strange coding issue
关键字:
#!/usr/bin/python3
# coding: utf-8
# Run: python3 fix.py
# See:
# https://github.com/rspeer/python-ftfy
# https://stackoverflow.com/questions/7861358/strange-characters-in-database-text-%C3%83-%C3%83-%C2%A2-%C3%A2-%E2%82%AC
import ftfy
# Set input_file
input_file = open('bad.sql', 'r', encoding="utf-8")
# Set output file
output_file = open ('good.sql', 'w')
# Create fixed output stream
stream = ftfy.fix_file(
input_file,
encoding=None,
fix_entities='auto',
remove_terminal_escapes=False,
fix_encoding=True,
fix_latin_ligatures=False,
fix_character_width=False,
uncurl_quotes=False,
fix_line_breaks=False,
fix_surrogates=False,
remove_control_chars=False,
# remove_bom=False,
normalization='NFC'
)
# Save stream to output file
stream_iterator = iter(stream)
while stream_iterator:
try:
line = next(stream_iterator)
output_file.write(line)
except StopIteration:
break
--
最后修改: admin on 2022-11-27 16:09:52 PST
※ 来源: homecox.com [来自: 98.]
|
|
|