Thanks for your replies, Bruce and Ronald, See my answer below:
2007/2/28, Bruce Van Allen <[EMAIL PROTECTED]>:
On 2/28/07 Manuel Souto Pico wrote: >... >But now I needed to upload some text files to an application which >expects a \n at the end of each new line and it didn't work. I had to >find and replace \r with \n in all the documents that I needed to >upload. > >I would be handy not to have to do that and get a \n instead of a \r >whenever I click enter in BBedit. What am I doing wrong? Aren't my >preferences well chosen? Is there any other option that I'm >overlooking? Take these things into account: 1. BBEdit always uses \r for newlines when it presents a file in an open window. So if you search within BBEdit, that's what you'll find.
Ok. I understand this and it's fine with me. It's more or less what I had understood the editor does.
2. When BBEdit saves or closes a file, it restores the newlines to whatever character(s) they were in the original, unless you've deliberately changed them.
I think I understand this too. That is, the format of the file (or the end of line) is what I determine in the Preferences (\n or LF) but the format that I see when i edit is always CR and is independent from the real format of the file. Let's say is like a virtual encoding.
3. Other applications and languages have their own ways of handling newlines. In Perl, for example, "\n" stands for the newline used in the operating system in which Perl is executing. In Linux/UNIX (including OS X), Perl's "\n" is a linefeed (LF), in Windows/DOS it's carriage return-linefeed (CRLF), and in Mac Classic it's a carriage return (CR).
Fine. Then, working in Mac Os X, the files I created with Perl must have LF's.
So the first question to ask is: when you say your application didn't work, what system was it executing in, and what system created the file (that is, which system's newline is used in the file)? What you're describing sounds like a mismatch of these.
Yes, I know there's a mismatch. That's what I tried to explain in my mail :) The application is in a server which I guess runs Linux or another branch of Unix. The files were created in my system (running Mac OS X), but I can't remember whether I created them pasting the lines from the Terminal in BBedit or whether the files were the output of one of my Perl scripts. I guess both things are the case.
How are you uploading the test files? With an FTP client, if you upload as text/ASCII, the file's newlines will be converted for you; if you upload as binary/raw data, the newlines won't be changed.
If was a web application: there was a 'Browse' button, then you select the file and you click 'Submit' :) Sorry if "uploading" wasn't the right term. In any case, the newlines shouldn't need to be converted because the application expects LF's and my editor is configured (in theory) to save files with LF's.
There are various ways to convert the newlines of a batch of files, but I'm not sure you really need to do manual conversions...
It wouldn't be much of a pain, I guess something like perl -i -e -p 's/\r/\n/gi' would do. But I would like to know what is wrong with the editor so I don't have to further process my files once I close the editor.
If the above doesn't help, then we need more information about your files and the application that doesn't work.
Does the information I provided suffice? Please tell me if you need anything else. I've noticed now there's an option "Use Unicode line breaks" in Preferences: Text Files (mine is checked) and also that at the bottom of the editor window there's a menu where you can choose between CR, LF, CRLF and Unicode (mine is set to Unicode). Can this have any relation? Thanks again! Manuel
- Bruce __bruce__van_allen__santa_cruz__ca__ -- ------------------------------------------------------------------ Have a feature request? Not sure the software's working correctly? If so, please send mail to <[EMAIL PROTECTED]>, not to the list. List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml> List archives: <http://www.listsearch.com/BBEditTalk.lasso> To unsubscribe, send mail to: <[EMAIL PROTECTED]>
-- ------------------------------------------------------------------ Have a feature request? Not sure the software's working correctly? If so, please send mail to <[EMAIL PROTECTED]>, not to the list. List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml> List archives: <http://www.listsearch.com/BBEditTalk.lasso> To unsubscribe, send mail to: <[EMAIL PROTECTED]>
