From d53245f8a3efb6194e94c1aa2c08d251d2a3b4fb Mon Sep 17 00:00:00 2001 From: Alvin Wong Date: Sat, 10 Apr 2021 19:40:33 +0800 Subject: [PATCH] Simplify some Python code --- Translations/make_translation.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Translations/make_translation.py b/Translations/make_translation.py index 296fc9a3..fc3ebbd0 100755 --- a/Translations/make_translation.py +++ b/Translations/make_translation.py @@ -608,14 +608,11 @@ def write_language(lang: dict, defs: dict, f: TextIO) -> None: f" // {offset + remapped.str_start_offset: >4}: {escape(str_table[j])}\n" ) str_offsets[j] = offset + remapped.str_start_offset - converted_str = convert_string(symbol_conversion_table, source_str) - f.write(f' "{converted_str}"') + converted_bytes = convert_string_bytes(symbol_conversion_table, source_str) + f.write(f' "{bytes_to_escaped(converted_bytes)}"') str_offsets[i] = offset - # Sanity check: Each "char" in `converted_str` should be in format - # `\xFF`, so the length should be divisible by 4. - assert len(converted_str) % 4 == 0 # Add the length and the null terminator - offset += len(converted_str) // 4 + 1 + offset += len(converted_bytes) + 1 f.write("\n};\n\n") def get_offset(idx: int) -> int: