On Jan 11, 4:49 pm, Todd B. [email protected] wrote:
Karl von Laudermann wrote:
If you’re using Mac OS X, rather than OS 9 or earlier,
then your text
files should be using LF as a line break, not CR.
I use both TextEdit and TextWrangler. Both put in \r\n
even if not, a proper line ending converter should just insert a CR
before each LF without causing any problems.
Well, er… umm… I wrote it. It replaces the \r with a blank. It’s
very fast (C code), doesn’t change the size of the file and converts
them in place. I simply drag and drop the file needing to be converted
onto my desktop icon and it’s done a split second later.
What should it be doing? If I changed the \r to a \n, wouldn’t I get
Ok, one of us is confused, and I think it’s you. Different OS’s
use and expect different line endings for text files. Specifically:
Unix and Mac OS X: \n
Classic Mac OS: \r
You said you were transferring files from a Mac to a PC. So I
assumed your files had \n line endings, and you used a converter to
add a \r before each \n, once the files were on the PC. But you’re
saying that using TextEdit and TextWrangler on the Mac, the files
already get \r\n line endings, which is what the PC expects. So no
conversion should be necessary when transferring them to a PC. And
this is suspicious anyway, because I would expect TextEdit and
TextWrangler to use unix line endings by default, so you would have to
have manually changed the preferences to use PC line endings.
If you were going from a PC to a Mac (or Linux or other Unix),
then you would want a converter to delete all the \r characters from
each \r\n pair. Note I said delete, but you say your program
replaces each \r with a blank, thus not changing the file size. So in
effect each line gets an extra blank at the end.
So, in summary:
- If you’re transferring a text file to a PC, you want to then
ensure that each line ends with \r\n.
- If you’re transferring a text file to a Mac, you want to then
ensure that each line ends with \n.
- And if you’re doing a conversion that strips the \r from each \r\n
pair, you want to delete the \r, not replace it with a blank.