Page 1 of 1

[NOT A BUG] Serious hexdump bug

Posted: 13 Jun 2014 19:11
by Marco
You can test it with latest beta and the attached file (it's supposed to be the header of an mp3 file).
Correct dump is

Code: Select all

49 00 44 00 33 00 04 00 00 00 80 00 00 00 03 00 28 00 06 00 
XY wrongly reports

Code: Select all

49 00 44 00 33 00 04 00 00 00 AC 20 00 00 03 00 28 00 06 00 
as a result of

Code: Select all

text hexdump(readfile(<curitem>), 1, "r");

Re: Serious hexdump bug

Posted: 13 Jun 2014 20:03
by admin
No file attached.

Re: Serious hexdump bug

Posted: 13 Jun 2014 20:09
by Marco
PS: I solved by using

Code: Select all

text hexdump(readfile(<curitem>), , "r");
meanwhile

Re: Serious hexdump bug

Posted: 13 Jun 2014 20:30
by admin
So, false alarm, right?

Re: Serious hexdump bug

Posted: 14 Jun 2014 09:20
by Marco
I found a way that gives the correct result (call it a workaround), but the bug is still there.

Re: Serious hexdump bug

Posted: 14 Jun 2014 09:32
by admin
I don't think there is the bug. These are the bytes:

Code: Select all

49 44 33 04 00 80 00 03 28 06 
And it is correctly returned by:

Code: Select all

text hexdump(readfile(<curitem>), , "r");
That's no workaround but correct scripting. :)

Your other code makes the wrong assumption that the file is a Unicode text file and therefore decodes it into a text string according to your locale. Makes no sense with a binary file.

Re: Serious hexdump bug

Posted: 14 Jun 2014 09:36
by Marco
Ah ok, thanks for the explanation. And I'm relieved now, I encountered this behaviour during a backup-related scripting session and you can imagine my reaction to seemingly corrupted data!

Re: [NOT A BUG] Serious hexdump bug

Posted: 14 Jun 2014 16:10
by PeterH
Just thought a bit about it - and don't understand.

The string supplied is just a set of some bytes - to show it in hex (dump 'raw') there should be no dependency to unicode, isn't it so? As I think the left = hexadecimal part of the dump has to show exactly the hex representation of the supplied string of bytes. No matter if it's to be interpreted as character, unicode, binary, or whatever. For me this is the reason for a hex dump: see, what's there.

Or do I miss something?

Re: [NOT A BUG] Serious hexdump bug

Posted: 15 Jun 2014 10:13
by admin
The string supplied is just a set of some bytes
A string is a locale-sensitive *interpretion* of a set of bytes.

Re: [NOT A BUG] Serious hexdump bug

Posted: 15 Jun 2014 11:35
by PeterH
admin wrote:
The string supplied is just a set of some bytes
A string is a locale-sensitive *interpretion* of a set of bytes.
We are talking about a (hex) dump, and the bytes to be dumped? I think the dump has to show what is, not not what can be interpreted.
To exaggerate: the dump of the binary number 0x'007b' would not be '31 32 33'.

The interpretation may apply to the right = alphanumeric column, or to the output on inverse dump.

Re: [NOT A BUG] Serious hexdump bug

Posted: 15 Jun 2014 12:07
by admin
readfile returns a locale aware string. hexdump does what you tell it to do with it (how to interprete it).