diff --git a/pygyat/parser.py b/pygyat/parser.py index 45d3905..3f4a244 100644 --- a/pygyat/parser.py +++ b/pygyat/parser.py @@ -59,7 +59,7 @@ def parse_glazes(filename): list of str: All imported modules, suffixed with '.gyat'. Ie, the name the imported files must have if they are pygyat files. """ - infile = open(filename, "r") + infile = open(filename, "r", encoding="utf-8") infile_str = "" for line in infile: @@ -119,8 +119,8 @@ def parse_file(filepath, filename_prefix, outputname=None, change_imports=None): """ filename = os.path.basename(filepath) - infile = open(filepath, "r") - outfile = open(filename_prefix + _change_file_name(filename, outputname), "w") + infile = open(filepath, "r", encoding="utf-8") + outfile = open(filename_prefix + _change_file_name(filename, outputname), "w", encoding="utf-8") # Read file to string infile_str_raw = "" diff --git a/scripts/py2gyat b/scripts/py2gyat index f5ada0d..f3145c2 100644 --- a/scripts/py2gyat +++ b/scripts/py2gyat @@ -155,7 +155,7 @@ def reverse_parse(filename, outputname): outputname (str): Path of destination file """ # Open a file as bytes - infile = open(filename, "r") + infile = open(filename, "r", encoding="utf-8") inlines = infile.readlines() # Read file to string @@ -191,7 +191,7 @@ def reverse_parse(filename, outputname): # replace anything in mappings.keys() with its value but opposite for value, key in GYAT2PY_MAPPINGS.items(): if "\\s" in value: - value = value.replace("\\s", "s") + value = value.replace("\\s+", " ") line = safe_substitute(value, key, line) line = re.sub( r'(?