From 3ca34171721d7b8f8062010fe9f94eb83463940b Mon Sep 17 00:00:00 2001 From: Ishigh1 Date: Tue, 13 Feb 2024 22:46:18 +0100 Subject: [PATCH] LADX: Added some resilience to non-ASCII player names (#2642) * Added some resilience to non-ASCII player names or items * Also the client, not even sure if switching to ascii is useful here * Split a long line in two --- LinksAwakeningClient.py | 3 ++- worlds/ladx/LADXR/utils.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/LinksAwakeningClient.py b/LinksAwakeningClient.py index f3fc9d2cdb72..a51645feac92 100644 --- a/LinksAwakeningClient.py +++ b/LinksAwakeningClient.py @@ -348,7 +348,8 @@ async def wait_for_retroarch_connection(self): await asyncio.sleep(1.0) continue self.stop_bizhawk_spam = False - logger.info(f"Connected to Retroarch {version.decode('ascii')} running {rom_name.decode('ascii')}") + logger.info(f"Connected to Retroarch {version.decode('ascii', errors='replace')} " + f"running {rom_name.decode('ascii', errors='replace')}") return except (BlockingIOError, TimeoutError, ConnectionResetError): await asyncio.sleep(1.0) diff --git a/worlds/ladx/LADXR/utils.py b/worlds/ladx/LADXR/utils.py index fcf1d2bb56e7..5f8b2685550d 100644 --- a/worlds/ladx/LADXR/utils.py +++ b/worlds/ladx/LADXR/utils.py @@ -146,7 +146,7 @@ def setReplacementName(key: str, value: str) -> None: def formatText(instr: str, *, center: bool = False, ask: Optional[str] = None) -> bytes: instr = instr.format(**_NAMES) - s = instr.encode("ascii") + s = instr.encode("ascii", errors="replace") s = s.replace(b"'", b"^") def padLine(line: bytes) -> bytes: @@ -169,7 +169,7 @@ def padLine(line: bytes) -> bytes: if result_line: result += padLine(result_line) if ask is not None: - askbytes = ask.encode("ascii") + askbytes = ask.encode("ascii", errors="replace") result = result.rstrip() while len(result) % 32 != 16: result += b' '