二进制文件 VS 文本文件

二进制文件和文本文件本质上无区别,但文本文件常被视为特定子集。在处理中,二进制文件的末尾EOF字符在文件拼接时可能丢失,导致问题。例如,两个10字节的二进制文件拼接后,第一个EOF被丢弃。为避免此类问题,不应让程序误将二进制文件当作文本文件。此外,二进制文件存储数据更高效,但不具移植性;文本文件虽然消耗更多CPU时间,但更兼容。
摘要由CSDN通过智能技术生成

Actually, there is no difference. But since text files are often
interpreted as such, it is wise to limit the contents to the proper
subset. For example:

 

>dir tt1.txt

02/06/2006  07:05p                  10 tt1.txt
               1 File(s)             10 bytes

The file tt1.txt contains 10 bytes, but we only see 7 if we type it:

 

>type tt1.txt

abcdefg

because "type" expects the file to be text and not binary and
interprets some of the contents instead of printing them. A dump
reveals why we only see 7:

                          DUMP.EXE    version 8-MAR-91
Block #    0        0
  0   61 62 63 64 65 66 67 0D 0A 1A FF FF FF FF FF FF    abcdefg...

Bytes 8, 9 & 10

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值