Unicode Combine
Verfasst: Mittwoch 24. Januar 2007, 19:17
Hab ein kleines Problem mit Unicode, ich mag den Buchstaben self.lastfocus[-1].GetValue()[:-1] mit dem Akzent event.GetEventObject().GetLabel() verbinden, das Problem ist das er mir immer folgende Fehlermeldung ausspuckt:
File "wxinterface.py", line 94
comb = u"\N{%s}" % combining
UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position 0-5: unknown Unicode character name
Danke fuers lesen!
File "wxinterface.py", line 94
comb = u"\N{%s}" % combining
UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position 0-5: unknown Unicode character name
Code: Alles auswählen
def CombineChars(self, event):
# event.GetEventObject().GetLabel() = "ˊ"
combining = (unicodedata.name(event.GetEventObject().GetLabel())).replace("MODIFIER","COMBINING")
comb = u"\N{%s}" % combining
tocombine = self.lastfocus[-1].GetValue()[-1]+comb
combined = unicodedata.normalize('NFC',tocombine)
# wxPython stuff
self.lastfocus[-1].SetValue("%s%s" % (
self.lastfocus[-1].GetValue()[:-1],
combined
)
)
self.lastfocus[-1].SetFocus()
self.lastfocus[-1].SetInsertionPoint(self.lastfocus[-1].GetLastPosition())