wxStyledTextCtrl and NUL

Vincent Wehren wrote:

>>>> Hi,
>>>>
>>>> (How) can I write a unicode string containing \u0000 to a
>>>> wxStyledTextCtrl? I was hoping that the null character would render >>>> as
>>>> the ASCII Mnemonic "NUL" ...

Robin Dunn wrote:

>> I had thought that my wxString converters would already handle
>> embedded NULLs. I'll check into it.

Looking forward to hearing your findings!

-- Vincent

Vincent Wehren wrote:

Vincent Wehren wrote:

>>>> Hi,
>>>>
>>>> (How) can I write a unicode string containing \u0000 to a
>>>> wxStyledTextCtrl? I was hoping that the null character would render >>>> as
>>>> the ASCII Mnemonic "NUL" ...

Robin Dunn wrote:

>> I had thought that my wxString converters would already handle
>> embedded NULLs. I'll check into it.

Looking forward to hearing your findings!

My general Python <--> wxString converters do handle embedded NULLs okay, but most of the wxStyleTextCtrl <--> Scintilla conversions assume NULL terminated strings.

I can make it work in an ansi build without too much trouble for most methods (but not SetText because it terminates at the null inside Scintilla,) but not for a unicode build. That is because in unicode mode Scintilla actually uses utf-8 internally, and so I am converting to/from unicode wxStrings and utf-8 strings and the MB2WC and WC2MB converters in wxWidgets all assume null-terminated buffers.

So I am inclined to leave it all as-is for now so I don't break something or add too much overhead to the common cases trying to make this corner case work. Instead I could add some special methods to the Python version of wxSTC that bypasses the wxString and lets you get/set utf-8 encoded text directly into the wxSTC. I probably won't get to that right away though...

ยทยทยท

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!