Page 1 of 1

Textpad's use of CR LF line endings

Posted: Tue Sep 10, 2002 7:06 pm
by Reuben Logsdon
Hello all,

When I create a Textpad file of type "Unix" with "ANSI" encoding, it uses normal LF endings like:

Hello{LF}
World{LF}
{LF}

But, when I use the "PC" type with "ANSI" encoding, it only uses CRLF on the final line:

Hello{LF}
World{LF}
{CR}{LF}

The "official" Windows line ending standard would call for {CR}{LF} terminators on each line. The Textpad help file claims that PC-type files have a CRLF terminator on each line, but they don't -- only the final 2 bytes of a multi-line file contain CRLF.

This behavior doesn't cause any problems for me but I would really like to know why they choose that convention. I have looked everywhere for info on this but can't find any good explanation.

Regards,
Reuben

Re: Textpad's use of CR LF line endings

Posted: Wed Sep 11, 2002 7:01 am
by Berend Hasselman
What exactly are you doing?

I tried to reproduce your results but couldn't.
I saved a file as Unix then resaved as PC and got exactly the correct line endings in both cases.

Berend Hasselman

Re: Textpad's use of CR LF line endings

Posted: Wed Sep 11, 2002 10:06 am
by Andreas
Same as Berend Hasselman with me - I get the correct endings.

Re: Textpad's use of CR LF line endings

Posted: Wed Sep 11, 2002 6:26 pm
by Reuben Logsdon
Thanks for checking this. I'm sorry, the problem was with my Perl script for analyzing line endings. I was using

if ($text =~ m!^(.*)\015(.*)$!s) {

instead of:

if ($text =~ m!^(.*?)\015(.*)$!s) {

which caused my script to only detect the second-to-last char. Some of my test files had mixed CRLF and LF endings and so the script was finding middle-file CR chars in those, and that prevented me from seeing my mistake immediately.

Thanks a lot for the feedback.