QScintilla/QsciScintillaCompat.py

changeset 3933
16d9ef6e6e89
parent 3656
441956d8fce5
child 4019
45e9ecae74d6
equal deleted inserted replaced
3931:ff8e034662d6 3933:16d9ef6e6e89
270 else: 270 else:
271 utf8Len = 1 271 utf8Len = 1
272 while len(ch) < utf8Len: 272 while len(ch) < utf8Len:
273 pos += 1 273 pos += 1
274 ch += self.byteAt(pos) 274 ch += self.byteAt(pos)
275 return ch.decode('utf8') 275 try:
276 return ch.decode('utf8')
277 except UnicodeDecodeError:
278 if pos > 0:
279 # try it one position before; maybe we are in the
280 # middle of a unicode character
281 return self.charAt(pos - 1)
282 else:
283 return ""
276 else: 284 else:
277 return ch.decode() 285 return ch.decode()
278 286
279 def byteAt(self, pos): 287 def byteAt(self, pos):
280 """ 288 """

eric ide

mercurial