Unicode considers newlines as control characters... oops

This commit is contained in:
rany 2021-05-22 20:33:34 +03:00
parent 465f5cdb0f
commit 185db5fe1c

View File

@ -23,7 +23,17 @@ def terminator(signo, stack_frame): sys.exit()
signal.signal(signal.SIGINT, terminator)
signal.signal(signal.SIGTERM, terminator)
def connectId(): return str(uuid.uuid4()).replace("-", "")
def removeIncompatibleControlChars(s): return "".join(ch for ch in s if unicodedata.category(ch)[0]!="C")
def removeIncompatibleControlChars(s):
output = []
for ch in s:
# We consider these control characters as whitespace
if ch in ['\t','\n','\r']:
pass
else:
abr = unicodedata.category(ch)
if abr.startswith("C"): continue
output += [ ch ]
return "".join(output)
def list_voices():
with urllib.request.urlopen(voiceList) as url: