BTW, is the file saved as Unicode or is it utf-8? They are not the same
thing and if you try to get the STC to load unicode as if it was utf-8
then you'll have lots of problems.
It's UTF-8
If I remove the BOM manually and save the file via self.SaveFile( path ),
Notepad++ tells me that the file is ANSI.
You have to manually strip the BOM from the file during load and
re-add it on save.
- Josiah
···
On Wed, Jun 25, 2008 at 5:52 AM, letij <e6d8wtu02@sneakemail.com> wrote:
BTW, is the file saved as Unicode or is it utf-8? They are not the same
thing and if you try to get the STC to load unicode as if it was utf-8
then you'll have lots of problems.
It's UTF-8
If I remove the BOM manually and save the file via self.SaveFile( path ),
Notepad++ tells me that the file is ANSI.
The standard load/save method is not buggy, it works great; I've been
using it to load/save unicode text in utf-8, utf-16 (and on platforms
that support it, utf-32) for years, never mind the various latin-*
encodings. It's just a matter of understanding what's going on.
In the case of Python, one character does not a utf-8 BOM make. It's
3 characters for utf-8. And if you really want to support unicode,
you should check for all BOM markers, decode your data based on what
is what, and use the SetText() with your decoded unicode (you don't
need to pass utf-8 encoded data to the STC, giving it an instance of
the actual Python unicode type works just fine).
- Josiah
···
On Wed, Jun 25, 2008 at 6:41 AM, letij <e6d8wtu02@sneakemail.com> wrote:
Thanks for the help! It appears that the standard load and save method of
StyledTextControl is buggy.