diff --git a/src/psweep/psweep.py b/src/psweep/psweep.py index baf9977..b8781a7 100644 --- a/src/psweep/psweep.py +++ b/src/psweep/psweep.py @@ -124,7 +124,10 @@ def flatten(seq): def file_write(fn: str, txt: str, mode="w"): makedirs(os.path.dirname(fn)) with open(fn, mode=mode) as fd: - fd.write(txt) + try: + fd.write(txt) + except UnicodeEncodeError: + fd.write(txt.encode("ascii", errors="xmlcharrefreplace").decode()) def file_read(fn: str):