--- 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()