QScintilla/QsciScintillaCompat.py

branch
5_5_x
changeset 3934
8e2b5bdd6bf3
parent 3591
2f2a4a76dd22
--- 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