Differences between text files and binary files

Source: Internet
Author: User

 

The storage of computer data is physically binary, so the difference between a text file and a binary file is not physical storage.

Mainly lies inEncoding MethodThe text file is based onCharacter encodingFiles are commonly encoded in ASCII, Unicode, UTF-8, and binary format.Value-basedEncoded file

The fixed-length encoding of a text file (there are also non-fixed-length such as UTF-8 at present). The binary file is a side-Length Encoding. It is up to you to determine how many bits represent a value. This encoding method causesBinary will save more space

For example, 201710000_00000000_00000000_00000001

 If it is displayed in notepad in ASCII encoding mode, it is null_null_null_soh.

In binary files, it is only 1 of the int type.

 

Binary files and text files are only encoded differently, so their advantages and disadvantages are the advantages and disadvantages of the encoding method.

The encoding of text files is based on the Character length, which makes decoding easier. binary files are longer encoded. Therefore, the encoding is flexible, the storage utilization is higher, and the decoding is more difficult (different binary file formats, there are different decoding methods), in space

For example, binary data can be expressed by one bit, but at least one character (1 byte) is required in text format)

 

The text mode and binary mode read and write operations are different only for line feed carriage returns. They have nothing to do with the file itself.

 

Original article: http://www.cnblogs.com/zhangjiankun/archive/2011/11/27/2265184.html

 

Differences between text files and binary files

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.