What Is a Text File?

A text file is a computer file, it is a typical sequential file, and its logical structure is a streaming file.

A text file is a line of characters
Due to its simple structure, text files are widely used to record information. It can avoid some problems encountered by other file formats. In addition, when part of the information in the text file is wrong, it is often easier to recover from the error and continue processing the rest. One disadvantage of text files is that it's

Text file definition

Computer storage is physically binary, so the difference between text files and binary files is not physical, but logical. The two differ only at the coding level.
In short, text files are character-based files. Common encodings include ASCII encoding, UNICODE encoding, and so on. A binary file is a file based on value encoding. You can specify a value (can be considered as a custom encoding) according to the specific application.
It can be seen from the above that the text file is basically fixed-length encoding (also non-fixed-length encodings such as UTF-8). Based on the characters, each character is fixed in the specific encoding. UNICODE generally occupies 16 bits. The binary file can be regarded as variable-length encoding because it is a value encoding. How many bits represent a value is entirely up to you.

Text file access

The text tool opens a file, first reads the binary bitstream corresponding to the file physically, then interprets the stream according to the selected decoding method, and then displays the interpretation result. In general, the decoding method you choose will be in the ASCII form (a character in the ASCII code is 8 bits). Next, it will interpret the file stream in 8 bits and 8 bits. No matter what file is opened, Notepad works according to the established character encoding (such as ASCII code), so when he opens the binary file, garbled characters are also inevitable, and decoding and decoding do not correspond.
The storage and reading of text files is basically a reverse process. The access of binary files is similar to that of text files, except that the encoding / decoding methods are different.

Pros and cons of text files

Because the difference between text files and binary files is only the encoding difference, their advantages and disadvantages are the advantages and disadvantages of encoding. It is generally believed that text file encoding is based on fixed-length characters and decoding is easy; binary file encoding is variable length, so it is flexible, storage utilization is higher, and decoding is difficult (different binary file formats have different decoding the way).
Under Windows, text files are not necessarily stored in ASCII, because ASCII code can only represent the 128 logo, open a txt file, and then save as, there is an option is encoding, you can choose the storage format, generally UTF -8 encoding format compatibility is better. The binary computer original language does not store compatibility.

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?