What does \x00 mean in binary file?
An ASCII file might be read or interpreted as having NULL-terminated strings, carriage returns & line-feeds, or other control characters, that are intended to be read and acted on. For example, a text reader might look for a line of text, where a line is "however many characters you see before you get to a linefeed"
A binary file is considered to be just a sequence of bytes - none of them has any special meaning, in the sens that a text-reader would interpret them.
\x00 is an example of a specific byte value (HEX 0), that might be interpreted in a special way by a text reader.
Bagong21
Updated on May 11, 2020Comments
-
Bagong21 almost 4 years
Once I asked a guy "what is the difference between ASCII and Binary files?"
And he said "Binary files always have \x00"
I've been searching about this and found What is the meaning of \x00 , \x04 in PHP
so the conclusion is, ASCII files don't have NULL character?
-
Bagong21 almost 13 yearsI found this good website mark0.net/hexdump.html and I uploaded an ASCII file, but I didn't find any NULL character? or maybe the website needs revision :D thanks anyway
-
Aater Suleman almost 13 yearsJust coz that one file didnt have a null doesnt mean NULL is not a part of ASCII. It happens to be the FIRST ASCII character according to ASCII:) cdrummond.qc.ca/cegep/informat/Professeurs/Alain/files/…
-
Aater Suleman almost 13 yearsGood. Then I am confused. I do not understand how you conclude that ASCII files do not have NULL by uploading one file and looking at its content?
-
Bagong21 almost 13 yearsdid you see stackoverflow.com/questions/1182812/… ? it's the link above, on this question
-
Bagong21 almost 13 yearsI didn't conclude anything, I've searched and tested. did you do that?
-
Aater Suleman almost 13 yearsyes I checked. How does that imply that ascii files don't contain NULLs? Does it say that somewhere?
-
Aater Suleman almost 13 yearsyup. tested, I can write and read an ascii file with a null in there. Hexdump shows the null if you write a null to a file, as expected. It just happens that the file you uploaded didn't have a null. You can write an ascii file using perl/C/python and put a null in there using \0. then open it using the editor of your choice to confirm it works and then upload it to hexdump. dude I studied computers for 10 years, i design them on a daily basis. they are simple devices, not magic. If null is a part of ascii, it can appear in an ascii file (by definition).
-
Schmuddi over 6 yearsThis is an old answer, but for the record: The generic statement that "ASCII files have NULL characters" is misleading, and the statement "every string in ASCII ends at a NULL" is just wrong. An ASCII file is just a file that contains only ASCII characters. It may or may not contain NULL. NULL has no specific meaning in an ASCII file, and it certainly doesn't act routinely as a termination marker. What is true is that some languages (e.g. C) use NULL to mark the end of a string in RAM. A programmer might decide to use this representation also in a file, but there's no obligation to do so.