强制使用 utf-8 存取

This commit is contained in:
2026-03-16 15:49:49 +08:00
parent fb9f3217e2
commit adb5dc01fb
+4 -4
View File
@@ -161,7 +161,7 @@ def _get_file_offset(inp: str) -> tuple[dict[str, list[int]], bool]:
current = ""
demand_outside = False
with open(inp) as f:
with open(inp, encoding="utf-8") as f:
while True:
line = f.readline()
if not line:
@@ -210,7 +210,7 @@ def parse_file(project: str, inp: str, version: str = "3") -> None:
sql_batch = SQLBatch(project)
_print_time("Second scan...")
with open(inp) as f:
with open(inp, encoding="utf-8") as f:
for s in levels:
if s not in offset:
continue
@@ -421,7 +421,7 @@ def convert_inp_v3_to_v2(inp: str) -> ChangeSet:
if os.path.exists(filename):
os.remove(filename)
with open(filename, "w") as f:
with open(filename, "w", encoding="utf-8") as f:
f.write(inp)
parse_file(project, filename, "3")
@@ -448,7 +448,7 @@ def import_inp(project: str, cs: ChangeSet, version: str = "3") -> bool:
os.remove(filename)
_print_time(f'Start writing temp file "{filename}"...')
with open(filename, "w", encoding="GBK") as f:
with open(filename, "w", encoding="utf-8") as f:
f.write(str(cs.operations[0]["inp"]))
_print_time(f'End writing temp file "{filename}"...')