fix: 解决unicode字符报错
This commit is contained in:
parent
17245a9bcf
commit
b99334ed12
@ -4,7 +4,7 @@ import sys
|
|||||||
|
|
||||||
def read_file_content(file_path: str) -> str:
|
def read_file_content(file_path: str) -> str:
|
||||||
try:
|
try:
|
||||||
with open(file_path, "r", encoding="utf-8") as file:
|
with open(file_path, "r", encoding="utf-8", errors="ignore") as file:
|
||||||
return file.read()
|
return file.read()
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print("Error: File not found.")
|
print("Error: File not found.")
|
||||||
@ -21,4 +21,4 @@ def remove_comments(code: str, extension: str) -> str:
|
|||||||
code = re.sub(r"//.*", "", code)
|
code = re.sub(r"//.*", "", code)
|
||||||
code = re.sub(r"/\*.*?\*/", "", code, flags=re.DOTALL)
|
code = re.sub(r"/\*.*?\*/", "", code, flags=re.DOTALL)
|
||||||
return code.strip()
|
return code.strip()
|
||||||
return code.strip()
|
return code.strip()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user