QScintilla/QsciScintillaCompat.py

branch
5_5_x
changeset 3934
8e2b5bdd6bf3
parent 3591
2f2a4a76dd22
equal deleted inserted replaced
3932:a909b9212f59 3934:8e2b5bdd6bf3
269 else: 269 else:
270 utf8Len = 1 270 utf8Len = 1
271 while len(ch) < utf8Len: 271 while len(ch) < utf8Len:
272 pos += 1 272 pos += 1
273 ch += self.byteAt(pos) 273 ch += self.byteAt(pos)
274 return ch.decode('utf8') 274 try:
275 return ch.decode('utf8')
276 except UnicodeDecodeError:
277 if pos > 0:
278 # try it one position before; maybe we are in the
279 # middle of a unicode character
280 return self.charAt(pos - 1)
281 else:
282 return ""
275 else: 283 else:
276 return ch.decode() 284 return ch.decode()
277 285
278 def byteAt(self, pos): 286 def byteAt(self, pos):
279 """ 287 """

eric ide

mercurial