The following is an example of the differences between text files and binary files. I think this is quite good. now I will share it with you and give you a reference. Let's take a look at the file encoding method. files can be divided into two types: ASCII code files and binary code files.
An ASCII file is also called a text file. when a file is stored on a disk, each character corresponds to one byte and is used to store the corresponding ASCII code. For example, the storage format of hundreds of thousands is:
ASC: 00110101 00110110 00110111 00111000
↓
Decimal Code: 5 6 7 8 occupies 4 bytes in total. The ASCII code file can be displayed by characters on the screen. for example, the source code file is an ASCII file, and the doscommand TYPE can be used to display the file content. Because it is displayed by characters, you can read the file content.
Binary files are stored in binary encoding.
For example, the storage format of hundreds of thousands is: 5678 00010110 occupies only two bytes. Although a binary file can be displayed on the screen, its content cannot be understood. When processing these files, the C system treats them as byte streams and does not differentiate the types. The start and end of the input and output streams are only controlled by the program, not by physical symbols (such as carriage returns.
Therefore, this type of file is also called a "streaming file ".
A file can be opened in text or binary mode. The difference between the two is that in text mode, carriage return is treated as a character '/N ', the binary mode considers it to be two characters: 0x0D and 0x0A. if you read 0x1B in the file, the text mode considers it to be the file terminator, that is, the binary model does not process the file, the text method converts the data in a certain way.
The difference between a text file and a binary file is the full content shared by the editor. I hope to give you a reference and support for PHP.
For more articles about text files and binary files, follow the PHP Chinese website!