Making editing bytes as text alway decode as UTF-8 instead of repr()

This commit is contained in:
Kovid Goyal 2021-02-16 09:07:49 +05:30
parent fd77db2da5
commit fa4713d1f3
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -278,6 +278,8 @@ class TextEdit(PlainTextEdit):
if self.smarts.override_tab_stop_width is not None:
self.tw = self.smarts.override_tab_stop_width
self.setTabStopWidth(self.tw * self.space_width)
if isinstance(text, bytes):
text = text.decode('utf-8', 'replace')
self.setPlainText(unicodedata.normalize('NFC', unicode_type(text)))
if process_template and QPlainTextEdit.find(self, '%CURSOR%'):
c = self.textCursor()