Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions multi_encoding_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@
base_encode = "gbk"

# 转换编码格式列表
convert_encode_list = ["utf8", "utf16", "gb2312", "gb18030"]
convert_encode_list = ["utf8", "gb2312", "gb18030"]

# 开始转换
base_path = Path("src") / base_encode
base_files = {file.name for file in base_path.glob("*.sas")}

for convert_encode in convert_encode_list:
convert_path = Path("src") / convert_encode
if not convert_path.exists():
convert_path.mkdir(parents=True)

# 删除 base_path 中已不存在的文件
for file in convert_path.glob("*.sas"):
if file.name not in base_files:
file.unlink()

# 复制或更新 base_path 中的文件
for file in base_path.glob("*.sas"):
content = file.read_text(encoding=base_encode)
(Path(convert_path) / file.name).write_text(
content, encoding=convert_encode
)
(Path(convert_path) / file.name).write_text(content, encoding=convert_encode)
Binary file removed src/utf16/ass2.sas
Binary file not shown.
Binary file removed src/utf16/ass3.sas
Binary file not shown.