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
This commit is contained in:
parent
55455914e6
commit
3ca3417172
|
@ -348,7 +348,8 @@ class LinksAwakeningClient():
|
||||||
await asyncio.sleep(1.0)
|
await asyncio.sleep(1.0)
|
||||||
continue
|
continue
|
||||||
self.stop_bizhawk_spam = False
|
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
|
return
|
||||||
except (BlockingIOError, TimeoutError, ConnectionResetError):
|
except (BlockingIOError, TimeoutError, ConnectionResetError):
|
||||||
await asyncio.sleep(1.0)
|
await asyncio.sleep(1.0)
|
||||||
|
|
|
@ -146,7 +146,7 @@ def setReplacementName(key: str, value: str) -> None:
|
||||||
|
|
||||||
def formatText(instr: str, *, center: bool = False, ask: Optional[str] = None) -> bytes:
|
def formatText(instr: str, *, center: bool = False, ask: Optional[str] = None) -> bytes:
|
||||||
instr = instr.format(**_NAMES)
|
instr = instr.format(**_NAMES)
|
||||||
s = instr.encode("ascii")
|
s = instr.encode("ascii", errors="replace")
|
||||||
s = s.replace(b"'", b"^")
|
s = s.replace(b"'", b"^")
|
||||||
|
|
||||||
def padLine(line: bytes) -> bytes:
|
def padLine(line: bytes) -> bytes:
|
||||||
|
@ -169,7 +169,7 @@ def formatText(instr: str, *, center: bool = False, ask: Optional[str] = None) -
|
||||||
if result_line:
|
if result_line:
|
||||||
result += padLine(result_line)
|
result += padLine(result_line)
|
||||||
if ask is not None:
|
if ask is not None:
|
||||||
askbytes = ask.encode("ascii")
|
askbytes = ask.encode("ascii", errors="replace")
|
||||||
result = result.rstrip()
|
result = result.rstrip()
|
||||||
while len(result) % 32 != 16:
|
while len(result) % 32 != 16:
|
||||||
result += b' '
|
result += b' '
|
||||||
|
|
Loading…
Reference in New Issue