Fix unicode chars in terminal w/ texitiowrapper

This commit is contained in:
amcmanu3 2024-01-11 16:11:08 -05:00
parent 1d32afa09d
commit 9d319b7460

View File

@ -1,5 +1,6 @@
from contextlib import redirect_stderr from contextlib import redirect_stderr
import os import os
import io
import re import re
import shutil import shutil
import time import time
@ -115,14 +116,17 @@ class ServerOutBuf:
ServerOutBuf.lines[self.server_id].pop(0) ServerOutBuf.lines[self.server_id].pop(0)
def check(self): def check(self):
text_wrapper = io.TextIOWrapper(
self.proc.stdout, encoding="UTF-8", errors="ignore", newline=""
)
while True: while True:
if self.proc.poll() is None: if self.proc.poll() is None:
char = self.proc.stdout.read(1).decode("utf-8", "ignore") char = text_wrapper.read(1) # modified
# TODO: we may want to benchmark reading in blocks and userspace # TODO: we may want to benchmark reading in blocks and userspace
# processing it later, reads are kind of expensive as a syscall # processing it later, reads are kind of expensive as a syscall
self.process_byte(char) self.process_byte(char)
else: else:
flush = self.proc.stdout.read().decode("utf-8", "ignore") flush = text_wrapper.read() # modified
for char in flush: for char in flush:
self.process_byte(char) self.process_byte(char)
break break