This attempts to fix the error:

"Error processing game output: 'gbk' codec can't decode byte 0xac in
position 33: illegal multibyte sequence"
as reported by nicotomia from the audiogames.net forum.
This commit is contained in:
Storm Dragon 2025-01-17 13:39:29 -05:00
parent 1a9b8d5c03
commit 6e9aaa9751

View File

@ -225,12 +225,26 @@ class SpeechHandler:
while True:
try:
line = process.stdout.readline()
# Keep gzdoom's existing functionality of lines being printed to the console.
print(line, end='')
if not line:
# Read raw bytes from stdout
rawLine = process.stdout.buffer.readline()
if not rawLine:
break
# Try different encodings
for encoding in ['utf-8', 'latin1', 'cp1252']:
try:
line = rawLine.decode(encoding)
break
except UnicodeDecodeError:
continue
else:
# If all encodings fail, skip this line
print(f"Warning: Could not decode line: {rawLine}", file=sys.stderr)
continue
# Keep gzdoom's existing functionality of lines being printed to the console
print(line, end='')
lineStr = line.strip()
# Wait for the initial separator before starting speech
@ -245,7 +259,7 @@ class SpeechHandler:
except Exception as e:
print(f"Error processing game output: {e}", file=sys.stderr)
break
continue # Continue processing instead of breaking
class MenuDialog(QDialog):
@ -1675,7 +1689,6 @@ class DoomLauncher(QMainWindow):
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
bufsize=1,
text=True,
env=dict(os.environ, PYTHONUNBUFFERED="1"),
startupinfo=startupinfo
)