Extended code to get a single chracter in the editor to be more robust. 5_5_x

Sat, 22 Nov 2014 13:17:43 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 22 Nov 2014 13:17:43 +0100
branch
5_5_x
changeset 3934
8e2b5bdd6bf3
parent 3932
a909b9212f59
child 3940
09db5a253c9c

Extended code to get a single chracter in the editor to be more robust.
(grafted from 16d9ef6e6e891249069e9ff4563a6a1b2ae236e0)

QScintilla/QsciScintillaCompat.py file | annotate | diff | comparison | revisions
--- a/QScintilla/QsciScintillaCompat.py	Wed Nov 19 18:53:41 2014 +0100
+++ b/QScintilla/QsciScintillaCompat.py	Sat Nov 22 13:17:43 2014 +0100
@@ -271,7 +271,15 @@
             while len(ch) < utf8Len:
                 pos += 1
                 ch += self.byteAt(pos)
-            return ch.decode('utf8')
+            try:
+                return ch.decode('utf8')
+            except UnicodeDecodeError:
+                if pos > 0:
+                    # try it one position before; maybe we are in the
+                    # middle of a unicode character
+                    return self.charAt(pos - 1)
+                else:
+                    return ""
         else:
             return ch.decode()
     

eric ide

mercurial