强制使用 utf-8 存取
This commit is contained in:
@@ -161,7 +161,7 @@ def _get_file_offset(inp: str) -> tuple[dict[str, list[int]], bool]:
|
|||||||
current = ""
|
current = ""
|
||||||
demand_outside = False
|
demand_outside = False
|
||||||
|
|
||||||
with open(inp) as f:
|
with open(inp, encoding="utf-8") as f:
|
||||||
while True:
|
while True:
|
||||||
line = f.readline()
|
line = f.readline()
|
||||||
if not line:
|
if not line:
|
||||||
@@ -210,7 +210,7 @@ def parse_file(project: str, inp: str, version: str = "3") -> None:
|
|||||||
|
|
||||||
sql_batch = SQLBatch(project)
|
sql_batch = SQLBatch(project)
|
||||||
_print_time("Second scan...")
|
_print_time("Second scan...")
|
||||||
with open(inp) as f:
|
with open(inp, encoding="utf-8") as f:
|
||||||
for s in levels:
|
for s in levels:
|
||||||
if s not in offset:
|
if s not in offset:
|
||||||
continue
|
continue
|
||||||
@@ -421,7 +421,7 @@ def convert_inp_v3_to_v2(inp: str) -> ChangeSet:
|
|||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
|
|
||||||
with open(filename, "w") as f:
|
with open(filename, "w", encoding="utf-8") as f:
|
||||||
f.write(inp)
|
f.write(inp)
|
||||||
|
|
||||||
parse_file(project, filename, "3")
|
parse_file(project, filename, "3")
|
||||||
@@ -448,7 +448,7 @@ def import_inp(project: str, cs: ChangeSet, version: str = "3") -> bool:
|
|||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
|
|
||||||
_print_time(f'Start writing temp file "{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"]))
|
f.write(str(cs.operations[0]["inp"]))
|
||||||
_print_time(f'End writing temp file "{filename}"...')
|
_print_time(f'End writing temp file "{filename}"...')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user