[wxPython-users] Styling in an STC editor
Josiah Carlson
jcarlson at uci.edu
Sun Dec 10 20:29:22 PST 2006
Torsten Bronger <bronger at physik.rwth-aachen.de> wrote:
> Hallöchen!
>
> I do my own syntax highlighting in an wx.py.editor.EditWindow. For
> achieving this, I say in my source
>
> ...
> text = self.GetTextRange(start, end)
> print len(text), end-start
>
> If the text contains some umlauts, this prints on the screen
>
> 1111 1123
>
> Consequently, the highlighting is broken. An .encode("utf-8") after
> the GetTextRange() solves the issue, however, I wonder why this is,
> and whether utf-8 is always correct, independent of the locale.
As per the documentation on scintilla.org, the StyledTextControl uses
utf-8 as an underlying data representation. So yes, text.encode('utf-8')
will generally produce correct results, regardless of locale.
You should, however, be careful of line endings. I can't remember off
the top of my head everything, but I seem to remember that there was
something quite annoying with the way line endings were handled in the
stc. Always 2 characters? Always 1 character? 2 characters on Windows,
1 on Linux? Do some investigation.
- Josiah
More information about the wxpython-users
mailing list