ASCII and binary files

Source: Internet
Author: User

From the file encoding methodFiles can be divided into ASCII files andBinaryTwo types of 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. ASCII code files can be displayed by characters on the screen, such as the sourceProgramThe file is an ASCII file. You can use the doscommand type to display the file content. Because it is displayed by characters, you can read the file content.

BinaryThe file isBinaryEncoding method to store files. For example, the storage format of hundreds of thousands is: 5678 00010110 occupies only two bytes.BinaryAlthough the file can be displayed on the screen,
However, the 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 ".

an object can be opened in text mode or binary mode, in text mode, carriage return is treated as a character '\ n', while 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 end of the file, that is, the binary model does not process files, the text method converts the data in a certain way.

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.