This article mainly introduces the difference between text files and binary files. Interested friends can refer to it. I hope it will be helpful to everyone.
From the perspective of file encoding, files can be divided into two types: ASCII code files and binary code files.
ASCII files are also called text files. When this kind of file is stored on the disk, each character corresponds to one byte, which is used to store the corresponding ASCII code. For example, the storage format of the number 5678 is:
##ASC code: 00110101 00110110 00110111 00111000 ↓ ↓ ↓ ↓
## Decimal code: 5 6 7 8 occupies a total of 4 bytes. ASCII code files can be displayed character by character on the screen. For example, the source program file is an ASCII file. Use the DOS command TYPE to display the contents of the file. Since it is displayed in characters, the contents of the file can be understood. Binary files store files in binary encoding.
For example, the storage form of the number 5678 is: 00010110 00101110 only takes up two bytes. Although binary files can be displayed on the screen, their contents cannot be read. When the C system processes these files, it does not distinguish between types. It treats them as character streams and processes them by bytes. The start and end of the input and output character streams are only controlled by the program and are not controlled by physical symbols (such as carriage returns).
So this kind of file is also called "streaming file".
A file can be opened in text mode or binary mode. The difference between the two is: In text mode, a carriage return is treated as a character '/n' , and the binary mode thinks it is two characters 0x0D, 0x0A; if 0x1B is read in the file, the text mode will think it is the end of file character, that is, the binary model will not process the file, and the text mode will process it according to a certain method to convert the data accordingly. The above is the entire content of this article, I hope it will be helpful to everyone's study.
Related recommendations:
binary filesEasy way to read and write
The above is the detailed content of The difference between text files and binary files. For more information, please follow other related articles on the PHP Chinese website!

二进制算法是一种基于二进制数的运算方法,其基本运算包括加法、减法、乘法和除法。除了基本运算外,二进制算法还包括逻辑运算、位移运算等操作。逻辑运算包括与、或、非等操作,位移运算包括左移和右移操作。这些操作都有对应的规则和操作数的要求。

win32和win64的区别是:1、win32是指Microsoft Windows操作系统的32位环境,win64是指Microsoft Windows操作系统的64位版本,比32位版本更加稳定快速;2、win32最高支持2G的内存,win64必须是4G以上内存;3、win64支持基于64位的处理器,而win32却不能完全支持;4、win32追求简洁,win64追求性能。

Vue3和Vue2的区别:更丰富的生命周期钩子Vue是一种流行的JavaScript框架,用于构建交互式的Web应用程序。Vue2是Vue.js的稳定版本,而Vue3是Vue.js的最新版本。Vue3带来了许多改进,其中之一是更丰富的生命周期钩子。本文将介绍Vue3和Vue2生命周期钩子的区别,并通过代码示例进行演示。Vue2的生命周期钩子在Vue2中,我们

二进制数以1和0表示。16位的十六进制数系统为{0,1,2,3…..9,A(10),B(11),……F(15)}为了从二进制表示转换为十六进制表示,位串id被分组为4位块,从最低有效侧开始称为半字节。每个块都替换为相应的十六进制数字。让我们看一个示例,以清楚地了解十六进制和二进制数字表示。001111100101101100011101 3 E 5 B&nb

EDVAC的两个重大的改进:一是采用二进制,二是完成了存贮程序,可以自动地从一个程序指令进到下一个程序指令,其作业可以通过指令自动完成。“指令”包括数据和程序,把它们用码的形式输入到机器的记忆装置中,即用记忆数据的同一记忆装置存贮执行运算的命令,这就是所谓存贮程序的新概念。

win7有好几个版本,对于这些琳琅满目的win7版本,很多朋友也是不知道这些win7版本有什么区别了,功能上哪个更好,哪个系统更适合自己,这里小编和大家介绍下win7企业版与win7旗舰版有什么区别的详细介绍,大家快来看看吧。1、Windows7企业版(Enterprise)这个版本面向企业市场的高级版本,主要对象是企业用户以及其市场,满足企业数据共享、管理、安全等需求。包含多语言包、UNIX应用支持、BitLocker驱动器加密、分支缓存(BranchCache)等。通过大量授权给有与微软签订

Golang如何读取二进制文件?二进制文件是以二进制形式存储的文件,其中包含了计算机能够识别和处理的数据。在Golang中,我们可以使用一些方法来读取二进制文件,并将其解析成我们想要的数据格式。下面将介绍如何在Golang中读取二进制文件,并给出具体的代码示例。首先,我们需要使用os包中的Open函数打开一个二进制文件,这将返回一个文件对象。然后,我们可以使

题目:轻松学会Go语言中16进制转二进制,需要具体代码示例在计算机编程中,经常会涉及到对不同进制数之间的转换操作。其中,16进制和二进制之间的转换是比较常见的。在Go语言中,我们可以通过一些简单的代码示例来实现16进制到二进制的转换,让我们一起来学习一下。首先,我们来了解一下16进制和二进制的表示方法。16进制是一种表示数字的方法,使用0-9和A-F来表示1


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version
