Char 0x00 in text for Text terminates output

Things you’d like to miss in the future...
Forum rules
You might want to read this if you're looking for priority service

:info: Please Include The Following Information
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: Use Your Profile Or Signature
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Char 0x00 in text for Text terminates output

Post 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:

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Char 0x00 in text for Text terminates output

Post 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.

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: Char 0x00 in text for Text terminates output

Post 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!
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Char 0x00 in text for Text terminates output

Post 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:

admin
Site Admin
Posts: 67271
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Char 0x00 in text for Text terminates output

Post by admin »


TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Char 0x00 in text for Text terminates output

Post by TheQwerty »


PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Char 0x00 in text for Text terminates output

Post 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.

admin
Site Admin
Posts: 67271
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Char 0x00 in text for Text terminates output

Post 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.

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Char 0x00 in text for Text terminates output

Post 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.

admin
Site Admin
Posts: 67271
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Char 0x00 in text for Text terminates output

Post 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. :)

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Char 0x00 in text for Text terminates output

Post 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?)

admin
Site Admin
Posts: 67271
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Char 0x00 in text for Text terminates output

Post 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.

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: Char 0x00 in text for Text terminates output

Post by bdeshi »

The obvious solution is: stop using Winows components and build your own. :mrgreen:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Char 0x00 in text for Text terminates output

Post 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:

admin
Site Admin
Posts: 67271
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Char 0x00 in text for Text terminates output

Post 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.

Post Reply