What does \x00 mean in binary file?

不羁的心 提交于 2019-12-03 07:48:38

问题


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?


回答1:


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.




回答2:


Wrong. ASCII files have NULL characters. In fact, every string in ASCII ends at a NULL.

ASCII files are files that only contain ASCII characters x0 - x127.

Binary files contain data and each individual byte can be an ascii character, an integer, pointer, etc. Its just how to write data to the file and how you rad it back.



来源:https://stackoverflow.com/questions/5954538/what-does-x00-mean-in-binary-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!