文本文件和二进制文件区别_文本文件和二进制文件之间的区别

文本文件和二进制文件区别

Here you will learn about difference between text file and binary file.

在这里,您将了解文本文件和二进制文件之间的区别。

Text Files

文字档案

Text files are special subset of binary files that are used to store human readable characters as a rich text document or plain text document. Text files also store data in sequential bytes but bits in text file represents characters.

文本文件是二进制文件的特殊子集,用于将人类可读字符存储为RTF文档或纯文本文档。 文本文件还按顺序字节存储数据,但文本文件中的位代表字符。

Text files are less prone to get corrupted as any undesired change may just show up once the file is opened and then can easily be removed.

文本文件不容易损坏,因为一旦打开文件,任何不想要的更改都可能会显示出来,然后可以轻松将其删除。

Text files are of two types:

文本文件有两种类型:

  • Plain text files: These files store End of Line (EOL) marker at the end of each line to represent line break and an End of File (EOF) at the end of the file to represent end of file.

    纯文本文件:这些文件在每行的末尾存储行尾(EOL)标记以表示换行符,并在文件的末尾存储文件末尾(EOF)来表示文件的末尾。

  • Rich text files: These files also follow the same schema as the plain text files but may also store text related information like text colour, text style, font style etc.

    富文本文件:这些文件也遵循与纯文本文件相同的模式,但也可以存储与文本相关的信息,例如文本颜色,文本样式,字体样式等。

Because of simple and standard format to store data, text files are one of the most used file formats for storing textual data and are supported in many applications.

由于存储数据的简单和标准格式,文本文件是用于存储文本数据的最常用的文件格式之一,并且在许多应用程序中都受支持。

Binary File

二进制文件

Binary file are those typical files that store data in the form of sequence of bytes grouped into eight bits or sometimes sixteen bits. These bits represent custom data and such files can store multiple types of data (images, audio, text, etc) under a single file.

二进制文件是那些典型的文件,它们以字节序列的形式存储数据,这些字节被分为八位或有时十六位。 这些位代表自定义数据,此类文件可以在单个文件下存储多种类型的数据(图像,音频,文本等)。

Binary file can have custom file formats and the developer, who designs these custom file formats, converts the information, to be stored, in bits and arranges these bits in binary file so that they are well understood by the supporting application and when needed, can easily be read by the supporting application.

二进制文件可以具有自定义文件格式,开发人员可以设计这些自定义文件格式,以位的形式转换要存储的信息,并以二进制文件的形式排列这些位,以便支持应用程序很好地理解它们,并在需要时可以易于被支持的应用程序阅读。

One most common example of binary file is image file is .PNG or .JPG. If one tries open these files using a text editor then, he/she may get unrecognizable characters, but when opened using the supporting image viewer, the file will be shown as a single image. This is because the file is in binary format and contains data in the form of sequence of bytes. When the text editor tries to read these bytes and tries to convert bits into characters, they get undesired special characters and display it to the user.

二进制文件的最常见示例是图像文件是.PNG或.JPG。 如果尝试使用文本编辑器打开这些文件,则他/她可能会收到无法识别的字符,但是当使用支持的图像查看器打开文件时,该文件将显示为单个图像。 这是因为文件是二进制格式,并且包含字节序列形式的数据。 当文本编辑器尝试读取这些字节并尝试将位转换为字符时,它们将获得不需要的特殊字符并将其显示给用户。

Binary files also store file information like file name, file format, etc., which may be included in the file as header to the file and is visible even when the file is opened in a text editor.

二进制文件还存储文件信息,如文件名,文件格式等,这些信息可以作为文件的标题包含在文件中,即使在文本编辑器中打开文件也可以看到。

Since binary files store data in sequential bytes, a small change in the file can corrupt the file and make it unreadable to the supporting application.

由于二进制文件按顺序字节存储数据,因此文件中的微小更改可能会损坏文件并使支持应用程序无法读取。

Difference between Text File and Binary File

Image Source

图片来源

文本文件与二进制文件–文本文件和二进制文件之间的区别 (Text File vs Binary File – Difference between Text File and Binary File)

Text FileBinary File
Bits represent character.Bits represent a custom data.
Less prone to get corrupt as changes reflect as soon as the file is opened and can easily be undone.Can easily get corrupted, even a single bit change may corrupt the file.
Can store only plain text in a file.Can store different types of data (image, audio, text) in a single file.
Widely used file format and can be opened using any simple text editor.Developed especially for an application and may not be understood by other applications.
Mostly .txt and .rtf are used as extensions to text files.Can have any application defined extension.
文本文件 二进制文件
位代表字符。 位代表自定义数据。
一旦文件打开,更改就反映出来,因此不容易损坏,可以轻松撤消。 容易损坏,即使只是一点点更改也可能损坏文件。
只能在文件中存储纯文本。 可以在一个文件中存储不同类型的数据(图像,音频,文本)。
广泛使用的文件格式,可以使用任何简单的文本编辑器打开。 专为某个应用程序开发,其他应用程序可能无法理解。
通常,.txt和.rtf用作文本文件的扩展名。 可以具有任何应用程序定义的扩展名。

Comment below if you have queries related to difference between text file and binary file.

如果您对文本文件和二进制文件之间的差异有疑问,请在下面评论。

翻译自: https://www.thecrazyprogrammer.com/2018/05/difference-between-text-file-and-binary-file.html

文本文件和二进制文件区别

  • 4
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值