From fec7fd43f039f8820956e7057e8dc4f3d3b679ec Mon Sep 17 00:00:00 2001 From: MarkJoy Date: Mon, 17 Jun 2024 10:57:23 +0700 Subject: [PATCH] Explicit open input .xml file with UTF-8 encoding --- biliass/__main__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/biliass/__main__.py b/biliass/__main__.py index 9eecc8d..bc37383 100644 --- a/biliass/__main__.py +++ b/biliass/__main__.py @@ -70,8 +70,11 @@ def main(): inputs = [] for file in args.file: try: - with open(file, "r" if args.format == "xml" else "rb") as f: - inputs.append(f.read()) + if args.format == "xml": + f = open(file, "r", encoding = "utf-8") + else: + f = open(file, "rb") + inputs.append(f.read()) except UnicodeDecodeError: logging.error(f"Failed to decode file {file}, if it is a protobuf file, please use `-f protobuf`") sys.exit(1)