Subject: Re: CRLF fun stuff again...
From: Duncan Sinclair (sinclair@dis.strath.ac.uk)
Date: Sat Feb 10 2001 - 06:11:40 EST
Hi,
Sorry for the continuing mailbox pollution...
Steve Freitas writes:
>I wrote:
>> But the transformation is reversible. the conversion is as follows:
>>
>> CR -> LF
>> LF -> CR
>>
>> You do the transformation twice and you get back an identical file.
>
>Not true with all files.
Yes true for all files. No matter what the 8-bit values "13" and "10"
mean, you can do this swap twice and you'll get back the exact same
file.
Here's a test with a binary jpeg file....
(Using GNU tr - Sun's "tr" doesn't cope with binary files - if you
repeat this test make sure you use one that does.)
quartz:~% sum duncan.jpg
32290 17 duncan.jpg
Original file's checksum is 32290
quartz:~% tr '\r\n' '\n\r' < duncan.jpg > foo.jpg
quartz:~% sum foo.jpg
13378 17 foo.jpg
Transform once, checksum is 13378
quartz:~% tr '\r\n' '\n\r' < foo.jpg > bar.jpg
quartz:~% sum bar.jpg
32290 17 bar.jpg
Transform a second time, checksum is back to 32290
Convinced yet???
Cheers,
Duncan.
This archive was generated by hypermail 2b28 : Sun Oct 14 2001 - 03:04:32 EDT