Document-related knowledge

file

1. The difference between text files and binary files

Text files and binary files are actually 存储files obtained by different data methods.

  • Write (store)

    The data is stored as characters, and the result is a text file. This process needs to be performed on the data 编码. When you 直接store the data , you get a binary file.

    Therefore, when the stored data is originally the same 字符数据, both 没有区别, when the stored data is non-character data, such as integer int i = 1, the text file stores the binary code of the string "1", while the binary file directly stores 1 The corresponding binary code is 1010.

  • Read (view)

    For text files and binary files to be read correctly, it is necessary to use and write corresponding reading methods. If you use Notepad software to open the text file correctly, but opening the binary file is garbled.

  • Pros and cons

    Text file binary file
    storage Need more space Need less space
    Program read and write (when display in binary format is required) Slower (requires tools to convert to raw data) Faster
    Human viewing (when displaying in text format is required) Faster Slower (needs tools to convert to character format)

2. The role of file suffix

It is the consensus of most software to distinguish file categories by extension.
The graphical resource manager of the operating system will associate commonly used extensions with the corresponding decoders.
No extension is associated with the operating system's command line. Regardless of windows or linux. The suffix name does not determine whether it is a text file. Binary files can also have the txt suffix name. The suffix name is only used to open the program and make notes for the user. It has nothing to do with the specific encoding of the file.

references

https://www.cnblogs.com/virusolf/p/5246660.html The difference between text files and binary files & the role of file suffixes
https://www.zhihu.com/question/62087216 Windows distinguishes why files must be extended name? I feel that the requirements on linux are not done like this

Guess you like

Origin blog.csdn.net/u013617791/article/details/104957296