m2ctx.py: Specify input encoding

This commit is contained in:
Aetias
2025-02-05 16:48:26 +01:00
parent c380ac51a4
commit 816c696255
+1 -1
View File
@@ -36,7 +36,7 @@ INCLUDE_REGEX = r'^\s*#\s*include\s*([<"][\S ]+[>"])\s*$'
# Finds all line comments and multiline comments
COMMENT_REGEX = r'\/\/.*$|\/\*(?:.|\r|\n)+?\*\/'
with open(args.file, 'r') as f:
with open(args.file, 'r', encoding=args.encoding) as f:
contents = f.read()
contents = re.sub(COMMENT_REGEX, '', contents, count=0, flags=re.MULTILINE)
includes = re.findall(INCLUDE_REGEX, contents, flags=re.MULTILINE)