diff --git a/tools/cheats.py b/tools/cheats.py index e7ca05b6..3620aa34 100644 --- a/tools/cheats.py +++ b/tools/cheats.py @@ -349,7 +349,7 @@ def main(): args = ap.parse_args() sys.stdout.reconfigure(errors='replace') # cheat names in a console without their characters m = Main(args.exefs / 'main') - text = args.patches.read_text() + text = args.patches.read_text(encoding='utf-8') files = cheat_files(args.mods, build_id(args.exefs / 'main')) cheats = [c for mod, f in files for c in parse(f.read_text(encoding='utf-8-sig', errors='replace'), mod)] sets, sites, status = [], [], [] @@ -357,7 +357,7 @@ def main(): classify(m, c) if c.sites: name = f'cheat_{c.key.lower()}' - label = c.name.encode('ascii', 'replace').decode() # recomp/patches.py reads the file as ASCII + label = c.name.encode('ascii', 'replace').decode() # a comment only, kept ASCII like the mod labels sets.append(f'set {name} TOTK_CHEAT_{c.key} {1 if c.kind == "master" else 0} # {label}') for a, repl in sorted(c.sites.items()): sites.append(f'site {name} main {a:x} {m.word(a):08x} {" ".join(f"{w:08x}" for w in repl)}') @@ -367,7 +367,7 @@ def main(): print(f'cheats: {c.kind:11} {c.name}' + (f' ({note})' if note else '')) if sets: text += ('\n# Cheats of the mods folder (tools/cheats.py)\n' + '\n'.join(sets) + '\n' + '\n'.join(sites) + '\n') - args.out.write_text(text) + args.out.write_text(text, encoding='utf-8') args.status.parent.mkdir(parents=True, exist_ok=True) args.status.write_text('\n'.join(status) + ('\n' if status else ''), encoding='utf-8') kinds = {} diff --git a/tools/exefs_patches.py b/tools/exefs_patches.py index 51417447..ee81712e 100644 --- a/tools/exefs_patches.py +++ b/tools/exefs_patches.py @@ -319,7 +319,7 @@ def build(args): m = Main(args.exefs / 'main') md = MainData(m) if args.data else None bid = m.nso.build_id - text = args.patches.read_text() + text = args.patches.read_text(encoding='utf-8') builtin = builtin_sites(text) files = patch_files(args.mods) sets, sites, status, data_lines, kinds = [], [], [], [], {} @@ -351,7 +351,7 @@ def build(args): if sets: text += ('\n# ExeFS patches of the mods folder (tools/exefs_patches.py)\n' + '\n'.join(sets) + '\n' + '\n'.join(sites) + '\n') - args.out.write_text(text) + args.out.write_text(text, encoding='utf-8') args.status.parent.mkdir(parents=True, exist_ok=True) args.status.write_text('\n'.join(status) + ('\n' if status else ''), encoding='utf-8') if args.data: diff --git a/tools/exefs_plugins.py b/tools/exefs_plugins.py index 73421bdb..8e51bb94 100644 --- a/tools/exefs_plugins.py +++ b/tools/exefs_plugins.py @@ -454,7 +454,7 @@ def plugin_files(mods): def emit(results, args): """--patches-out and --status from the checked plugins. results: one (module, its NSO file, its record or None, the record's directory, hooks, reasons) per plugin of the layout; no reasons: accepted.""" - text = args.patches.read_text() if args.patches else '' + text = args.patches.read_text(encoding='utf-8') if args.patches else '' builtin = builtin_sites(text) status, sets = [], [] files = {str(f.resolve()): (m, rel, f) for m, rel, f in plugin_files(args.mods)} @@ -482,7 +482,7 @@ def emit(results, args): if over else '')) if sets: text += '\n# Mod plugins (tools/exefs_plugins.py)\n' + '\n'.join(line for s in sets for line in s) + '\n' - args.patches_out.write_text(text) + args.patches_out.write_text(text, encoding='utf-8') args.status.parent.mkdir(parents=True, exist_ok=True) args.status.write_text('\n'.join(status) + ('\n' if status else ''), encoding='utf-8')