Subject: Re: CRLF fun stuff again...

From: Paul Schinder <[email-masked]>
Date: Sat, 10 Feb 2001 09:45:57 -0500

At 11:11 AM +0000 2/10/01, Duncan Sinclair wrote:
I missed this before.

>
>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???

The transformations you're using aren't the ones that netatalk does 
(or at least netatalk did in the past before I turned it off).  These 
are reversible.  netatalk does

tr '\r' '\n'  to Unix and tr '\n' '\r' to Mac OS.

That's why people are warning about data corruption.

Maybe netatalk should do what you're doing here.  Personally I'd 
still leave it off.

>Cheers,
>Duncan.

-- 
--
Paul J. Schinder
NASA Goddard Space Flight Center
Code 693
[email-masked]

---

From: "Tom Watson" <[email-masked]>
Date: Sat, 10 Feb 2001 13:05:02 -0800

On Sat, 10 Feb 2001 11:05:01 -0500 (EST), [email-masked] wrote:
<<<deletia>>>
> >tr '\r' '\n'  to Unix and tr '\n' '\r' to Mac OS.
<<<deletia, including some code>>>

The "secret" to all of this is to swap BOTH characters at the same
time.  Then the process is reversable.  Doing ONLY one is a recipe
for disaster.  You can easily see how this works by taking a
simple sentence and doing:

$ tr "ab" "ba" <source >dest

If you do it back, it comes out the same way.

Look at how the program "rot13" works for BOTH encoding and decoding.

Of course, doing this in the AFP server is a little crazy, but that
is another matter.  If it IS done, then someone should save that fact
in the "finder comments" or some such so that is is known to all.

That is another topic...
-- 
Tom Watson         Generic short signature
[email-masked]     (I'm at home now)