QssStylesheetEditor
QssStylesheetEditor copied to clipboard
fix UnicodeEncodeError
error ->
Traceback (most recent call last):
File "E:\Projects\Python\QssStylesheetEditor\src\ui\mainwin.py", line 540, in save
self.saveAs()
File "E:\Projects\Python\QssStylesheetEditor\src\ui\mainwin.py", line 553, in saveAs
self.editor.save(self.file.encode("utf-8"))
File "E:\Projects\Python\QssStylesheetEditor\venvtest\Lib\site-packages\CodeEditor\editor.py", line 366, in save
outfile.write(self.text())
File "C:\Users\ammar\AppData\Local\Programs\Python\Python311\Lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode characters in position 513-517: character maps to <undefined>
please, update lib CodeEditor
in editor.py -> Editor
class -> save
method:
def save(self, filename):
"""Save the editor contents to the given filename."""
with open(filename, 'w', newline='', encoding="utf-8") as outfile:
# 不指定newline,则换行符为各系统默认的换行符(\n, \r, or \r\n, )
# newline=''表示不转换
outfile.write(self.text())
self.setModified(False)