Re: carriage return & line feeds
Re: carriage return & line feeds
- Subject: Re: carriage return & line feeds
- From: Christopher Nebel <email@hidden>
- Date: Fri, 8 Jun 2001 12:29:41 -0700
On Friday, June 8, 2001, at 10:19 AM, Arthur J Knapp wrote:
Chris Nebel wrote:
Unix: ASCII character 10 (aka "\n" to Perl and C users, aka line feed)
Hey, you leave Perl out of this!
and clarify things a little: "\n" is platform *dependent* in Perl, and
adjusts itself nicely when reading/writing files on mac/unix/windows.
Very
helpful for writing platform *independent* scripts involving file I/O.
"\n"
is ascii character 10 in Perl only on unix platforms.
JavaScript OSA is the same way. Personally, I find it confusing.
I genuinely didn't know about this behavior in Perl. No slight
intended; I have a lot of respect for Perl, even if it does look like
line noise sometimes. ;) The solution to Arthur's problem, at least in
languages that support it, is to use the raw ASCII value: if you want a
line feed no matter what, you say "\012" or "\0x0a". I'd like to add a
general character-escaping scheme to AppleScript, but it's been a
relatively low priority.
Decent script editors don't change escaped-characters into their
literal format:
set someString to "Hello\rWorld"
-- after compile:
set someString to "Hello
World"
I mean, it kind of defeats the whole purpose of escaping in the
first place, doesn't it?
<Cough.> Yes, I'm aware of the problem. It bugs me, too. The problem
is, what if you put a literal return in there in the first place? It
would be rude to turn it into "\r", but we don't currently have a way to
track exactly what you typed. I'll have to think more about that, but I
suspect it's unmanageable. Maybe a preference somewhere...
--Chris Nebel
AppleScript Engineering