Page 1 of 2

Char 0x00 in text for Text terminates output

Posted: 11 Feb 2015 17:56
by PeterH
Maybe 1/2 of a :bug: :biggrin: - but suddenly very disturbing: if text to be shown by Text, Msg or Echo contains a hex null character ('NUL'), output is ended at this position.
I try to display a list of some Properties of a file. Several of them end on a 0x00, at least one ends on several of those. Not good when output of the list ends at the first 0 position.

I think these command should either ignore NULs, or replace them by something.

By the way: MSG with a big number of lines creates a *very* big window, not scrollable, reaching to the bottom of my cellar. :? I.e. most of it can't be seen. Looks rather strange :roll:

Re: Char 0x00 in text for Text terminates output

Posted: 11 Feb 2015 18:04
by TheQwerty
As noted here it also applies to IFilter results in MDBU.

I'm not sure replacing with CRLFs would also make sense for these dialog SC.
Though the only time I've run into it with them is (ab)using GetKey to obtain a list of keys within a section, and in that case CRLF wouldn't be a bad replacement.

Re: Char 0x00 in text for Text terminates output

Posted: 11 Feb 2015 18:24
by bdeshi
PeterH wrote:By the way: MSG with a big number of lines creates a *very* big window, not scrollable, reaching to the bottom of my cellar. :? I.e. most of it can't be seen. Looks rather strange :roll:
Yeah, use echo, the little brother that can.
This was mentioned before although maybe not prominently enough for Don to notice. :ninja:

ed: re topic: why should NULL be replaced by something else? I vote for replacing NULL with nothing. They're synonymous!

Re: Char 0x00 in text for Text terminates output

Posted: 11 Feb 2015 18:46
by PeterH
First the unimportant: looong long ago I made a note: Echo is simple form of Msg -> don't use. For this it seams the other way round...
(But in general I want to use Text, tried the others only to compare. So I don't mind :ninja: )

@ NULs: I don't think replacing with CRLF would be good. I construct a kind of table, showing values of variables. If such a value contains a NUL leading to CRLF you can forget all formatting. :shock: But same is for not replacing by something but ignoring them: the width can't be calculated :cry:
So best for me would be to replace them by middle-dot, as invalid characters in dumps are. :ugeek:
But OK: better ignore than terminate output :mrgreen:

Re: Char 0x00 in text for Text terminates output

Posted: 12 Feb 2015 09:48
by admin

Re: Char 0x00 in text for Text terminates output

Posted: 12 Feb 2015 15:25
by TheQwerty

Re: Char 0x00 in text for Text terminates output

Posted: 12 Feb 2015 21:57
by PeterH
Hmmm. My point of view: not fixed :cry:

Reason: 2 different things!
Fixed is that property() returns no more 0x00. :appl:
Not fixed is that Text (and other) commands truncate output on reaching a 0x00, suppressing the rest. :ninja:

OK: it might be of no sense to display NUL - but the result? I didn't do it at will! Multiple of time I would have needed for the script itself was needed to
- recognize that reason for the "short display" were the NULs (wer denkt an sowas...)
(And they were just for the very first property to return a result :evil: )
- coding to recognize+suppress NUL at the end of strings (it seemed they just appeared there)
- but then finding a value with more than 0x100 times 0x00 :shock:
- coding new (and better) logic to replace any NUL
And believe me: this is the true story told short!

It would have been much easyer if, from beginning, I would have seen the complete output. And I think I would have accepted any kind of display for NUL instead of coding around.

So, for me: it doesn't matter too much how Text (& Co) display a NUL, but it should never ever abend the complete output.

Sorry: this is my point of view.

Re: Char 0x00 in text for Text terminates output

Posted: 13 Feb 2015 11:18
by admin
PeterH wrote:
Hmmm. My point of view: not fixed :cry:

Reason: 2 different things!
Fixed is that property() returns no more 0x00. :appl:
Not fixed is that Text (and other) commands truncate output on reaching a 0x00, suppressing the rest. :ninja:

OK: it might be of no sense to display NUL - but the result? I didn't do it at will! Multiple of time I would have needed for the script itself was needed to
- recognize that reason for the "short display" were the NULs (wer denkt an sowas...)
(And they were just for the very first property to return a result :evil: )
- coding to recognize+suppress NUL at the end of strings (it seemed they just appeared there)
- but then finding a value with more than 0x100 times 0x00 :shock:
- coding new (and better) logic to replace any NUL
And believe me: this is the true story told short!

It would have been much easyer if, from beginning, I would have seen the complete output. And I think I would have accepted any kind of display for NUL instead of coding around.

So, for me: it doesn't matter too much how Text (& Co) display a NUL, but it should never ever abend the complete output.

Sorry: this is my point of view.
The only way to get NULLs into text boxes is via scripting. It's the scriptors job to handle the output. A NULL character is information (in the C/C++ world it means: end of text). IMO XYplorer should not automatically alter this information.

Re: Char 0x00 in text for Text terminates output

Posted: 13 Feb 2015 12:10
by PeterH
We are not on the same view?

I think a NUL character (ASCII etc.) is like "show nothing",
C & others treat a byte 0x00 as EndOfString, superseding the former.

A script is not C, it's XY!
XY does not terminate the string at 0x00 (check the variable, assign it to another) - but it terminates it's display!
For me this is inconsistent. :?

If a NUL in a string is not displayed (or replaced by '.'. don't mind) it's at most a minor alteration.
If 80% of text are not shown it's a major alteration.

In the end: the scripter is responsible for XY handling a string with imbedded NUL, but terminating it's output on display. :arrow: :?:
( :arrow: Rules of C for display operation, but not for handling strings!)

OK: I can hope that XY, system, or whatever will not unexpectedly (by error, or by missing knowledge of me) supply variables containing 0x00, or I or someone else will have some hours of debugging (or give up). Or behavior of Text (etc) are changed.

So for me: terminating output at NUL is wrong. :mrgreen:

Yes: I can live with it. And (till next occurence :whistle: ) it's only minor.
But for me it's wrong.

Re: Char 0x00 in text for Text terminates output

Posted: 13 Feb 2015 12:18
by admin
Not XY terminates the display, but Windows. Windows edit boxes do not tolerate NULLs.

Where do you get your NULLs, and what hinders you to replace them by some character yourself? This is programmer's everyday life. :)

Re: Char 0x00 in text for Text terminates output

Posted: 13 Feb 2015 14:00
by PeterH
OK: at least an explanation that can be understood a bit more... :biggrin:

But: I 'received' my NULs from XY. :mrgreen: A risk immanent to any source of text. Be it the script, any file, any returned var from any environment,...
The result could be that any (interested) scripter could, before displaying text, replace any NUL by 'anything else'. For the "Win edit box" producing unexpected/unwanted results, or for you using it.
Or you could do it before calling Win - to make the annoyance smaller. Why not?

(Repeat: for scripting variables NUL is a character, not end-of-data. But for Text it is EOD! Rather hard for a scripter, isn't it?)

Re: Char 0x00 in text for Text terminates output

Posted: 14 Feb 2015 10:36
by admin
Automatic modification of data -- not good. Whatever character I use as replacement, you will never know whether the original data had this character or NULL.

Re: Char 0x00 in text for Text terminates output

Posted: 14 Feb 2015 12:25
by bdeshi
The obvious solution is: stop using Winows components and build your own. :mrgreen:

Re: Char 0x00 in text for Text terminates output

Posted: 14 Feb 2015 15:16
by PeterH
SammaySarkar wrote:The obvious solution is: stop using Winows components and build your own. :mrgreen:
I assume you meant Don?
For the mentioned solution he would have to think about how he would handle NUL.
OK: had a look at wikipedia:
  • The original meaning of this character was like NOP—when sent to a printer or a terminal, it does nothing (some terminals, however, incorrectly display it as space). ...
But it's a sporadic problem between me and Don: on MS doing something wrong he doesn't want to correct it, as people could be puzzled.
(I remember: on deleting a junction on WXP the folder that the junction pointed to was (illegally) deleted, too. [Starting with Vista MS corrected it...] Don said it's unsave not to delete it like XP does - and created a special command "Delete Junction" for the ability to delete a Junction without also deleting the original data. So everyone just deleting a junction will lose the original data... :shock: )

Sad to say: I don't understand this. :roll:

Re: Char 0x00 in text for Text terminates output

Posted: 04 Mar 2015 16:50
by admin
admin wrote:Automatic modification of data -- not good. Whatever character I use as replacement, you will never know whether the original data had this character or NULL.
The flu restructured my brain.

Next beta (v14.80.0239):

Code: Select all

    * SC echo, msg, text: Experimentally now any NULLs in the displayed text 
      are replaced by spaces. Reason: The first NULL would stop any further 
      display in a Windows Edit box. Now you see more in such cases.