MicroPython interface eric7

Tue, 10 Oct 2023 14:53:23 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 10 Oct 2023 14:53:23 +0200
branch
eric7
changeset 10234
6b6fe61bba38
parent 10233
51a6649ba79d
child 10235
4a12b160094c

MicroPython interface
- Corrected the MicroPython REPL widget to be able to deal with unicode output.

src/eric7/MicroPython/MicroPythonReplWidget.py file | annotate | diff | comparison | revisions
--- a/src/eric7/MicroPython/MicroPythonReplWidget.py	Mon Oct 09 19:48:41 2023 +0200
+++ b/src/eric7/MicroPython/MicroPythonReplWidget.py	Tue Oct 10 14:53:23 2023 +0200
@@ -567,7 +567,18 @@
             else:
                 tc.deleteChar()
                 self.setTextCursor(tc)
-                self.insertPlainText(chr(data[index]))
+                # unicode handling
+                if data[index] & 0b11110000 == 0b11110000:
+                    length = 4
+                elif data[index] & 0b11100000 == 0b11100000:
+                    length = 3
+                elif data[index] & 0b11000000 == 0b11000000:
+                    length = 2
+                else:
+                    length = 1
+                txt = data[index:index + length].decode("utf8")
+                index += length - 1  # one more is done at the end
+                self.insertPlainText(txt)
 
             index += 1
 

eric ide

mercurial