<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<div>> On 25 Apr 2017, at 6:16 pm, Matic Kukovec <kukovecmatic@hotmail.com> wrote:<br>
> > <br>
> > <br>
> > > On 25 Apr 2017, at 5:08 pm, Matic Kukovec <kukovecmatic@hotmail.com> wrote:<br>
> > > > <br>
> > > > Hi guys,<br>
> > > > <br>
> > > > I just noticed that when adding strings that contain null characters ('\0') using the setText method,<br>
> > > > QScintilla cuts off the string at the first null character it finds. To be sure I opened the same text saved<br>
> > > > to a file with Notepad++ and SciTE and there the null characters appear.<br>
> > > > <br>
> > > > Is this a bug or should strings with null characters be handled differently?<br>
> > > > I used this example to for testing:<br>
> > > > qscieditor.setText("Test\nText\nIn\n\0An\nQscintilla\nEditor")<br>
> > > <br>
> > > Is that C++ or Python?<br>
> > > <br>
> > > setText() uses the low-level Scintilla SCI_SETTEXT which accepts a '\0' string, ie. you will get the same result if you used Scintilla.<br>
> > > <br>
> > > Phil<br>
> > <br>
> > Hi Phil,<br>
> > <br>
> > I'm using Python3 and before I tried setText and now I tried as you suggested:<br>
> > qscieditor.SendScintilla(SCI_SETTEXT, bytes("Test\nText\nIn\n\0An\nQscintilla\nEditor", encoding="ascii"))<br>
> > and I get the same result.<br>
> > I looked into the C++ setText method and it uses this line:<br>
> > SendScintilla(SCI_SETTEXT, ScintillaBytesConstData(textAsBytes(text)));<br>
> > Is there maybe an error in how the ScintillaBytesConstData or textAsBytes convert the text?<br>
> > I'm only guessing here.<br>
> <br>
> You misunderstand. I was saying that the behaviour you see is the way Scintilla works.<br>
> <br>
> Phil<br>
<br>
Are you sure? <br>
Then how do SciTE and Notepad++ do this without cutting off at the first '\0' character as they also use Scintilla?<br>
<br>
Thanks,<br>
Matic<br>
<br>
</div>
</div>
</body>
</html>