简体   繁体   English

二进制文件和基于ASCII的文件比较有什么区别?

[英]What is the difference between binary and ASCII based file comparison?

If I use a file comparison tool like fc in Windows, you can choose between ASCII and binary comparison. 如果在Windows中使用fc类的文件比较工具,则可以在ASCII和二进制比较之间进行选择。

What is the actual difference between these two comparisons? 这两个比较之间的实际区别是什么? If I compare two ASCII files, don't I want the binary data of the files to be identical? 如果我比较两个ASCII文件,是否不希望文件的二进制数据相同?

WARNING: this is 5 year old loose remembrance of knowledge from uni 警告:这是5年前对uni知识的宽松记忆

Binary representation means you compare the binary exactly, and ascii is a comparison of data type. 二进制表示表示您完全比较二进制,而ascii是数据类型的比较。 to put it in a simple case the char 'A' is a representation of 01000001, but that is also an 8 bit integer equal to '65', so that means A = 65 in binary. 简而言之,char'A'表示01000001,但这也是一个等于'65'的8位整数,因此意味着A = 65(二进制)。 so if you were doing A + A as a string and 65 43 65 (43 is '+' in binary to decimal), in binary they would be equivalent, but in ascii they would not. 因此,如果您将A + A作为字符串和65 43 65(二进制到十进制为43是“ +”),则在二进制中它们是等效的,但在ascii中则不是。 This is a very loose explanation and i'm sure i missed a lot, but that should sum it up loosely. 这是一个非常宽松的解释,我敢肯定我错过了很多,但这应该可以概括起来。

In a text file you want ASCII because you write in ascii characters. 在文本文件中,您需要ASCII,因为您使用的是ASCII字符。 In say, a program state saved to a file you want binary to get a direct comparison. 换句话说,程序状态保存到您要二进制文件进行直接比较的文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM