QScintilla/QsciScintillaCompat.py

changeset 3933
16d9ef6e6e89
parent 3656
441956d8fce5
child 4019
45e9ecae74d6
--- a/QScintilla/QsciScintillaCompat.py	Tue Nov 18 20:17:46 2014 +0100
+++ b/QScintilla/QsciScintillaCompat.py	Sat Nov 22 13:17:43 2014 +0100
@@ -272,7 +272,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