Fix mojibake in DX cluster and RBN spot comments where the source uses UTF-8

This commit is contained in:
Ian Renton
2026-09-20 19:11:53 +01:00
parent 9272766ffb
commit 6037e742cc
11 changed files with 29 additions and 17 deletions
+10
View File
@@ -156,3 +156,13 @@ def get_callsign_object_from_pyhamtools_callinfo(callsign, callinfo):
except (KeyError, ValueError):
# Unknown callsign, can't look anything up, return a Callsign object with basic data so that gets cached
return Callsign(call=callsign)
def decode_telnet_bytes(data: bytes) -> str:
"""Decode a line of text received from a telnet connection, which might be UTF-8 or Latin-1 depending on the
whims of the server owner."""
try:
return data.decode("utf-8")
except UnicodeDecodeError:
return data.decode("latin-1")