alexlance / signal-message-exporter

Export SMS, MMS, and Signal messages out of Signal
39 stars 6 forks source link

Fix Encoding On Output File #7

Closed JF47 closed 1 year ago

JF47 commented 1 year ago

On Windows 10:

Exception: Traceback (most recent call last): File "signal-message-exporter.py", line 310, in <module> root.writexml(f, encoding="utf-8", standalone="yes") File "\lib\xml\dom\minidom.py", line 1828, in writexml node.writexml(writer, indent, addindent, newl) File "\lib\xml\dom\minidom.py", line 897, in writexml node.writexml(writer, indent+addindent, addindent, newl) File "\lib\xml\dom\minidom.py", line 886, in writexml _write_data(writer, attrs[a_name].value) File "\lib\xml\dom\minidom.py", line 308, in _write_data writer.write(data) File "\lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\u263a' in position 0: character maps to <undefined>

To fix this, simply open the file with the correct encoding by adding ", encoding="utf-8"":

with open("sms-backup-restore.xml", "w", encoding="utf-8") as f:

alexlance commented 1 year ago

Brilliant - thank you for the fix! I've added it in commit https://github.com/alexlance/signal-message-exporter/commit/96d59b09006688d36021864a8c636413f7bc0c03