Re: linebreak in a shell script; was Re: What's wrong with this call to zip?
Re: linebreak in a shell script; was Re: What's wrong with this call to zip?
- Subject: Re: linebreak in a shell script; was Re: What's wrong with this call to zip?
- From: Philip Aker <email@hidden>
- Date: Fri, 29 Feb 2008 07:48:32 -0800
On 08-02-28, at 18:50, Paul Berkowitz wrote:
On 2/28/08 6:03 PM, "Philip Aker" <email@hidden> wrote:
On 08-02-28, at 15:57, Shane Stanley wrote:
set x to "blah" & return & linefeed & "blah"
count of characters of x --> 9
character 5 of x --> in Script Debugger, "\r\n"
id of character 5 of x --> {13, 10}
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {linefeed}
count of text items of x --> 1
set AppleScript's text item delimiters to oldDelims
(The result is the same if you use ASCII character 10 instead of
the built-in linefeed.)
Bugginess reproducible in Script Editor:
set x to ("blah" as Unicode text) & (return as Unicode text) &
(linefeed as Unicode text) & "blah"
set scount to count of characters of x
set chr5 to character 5 of x
set id5 to id of character 5 of x
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {linefeed}
set ccount to count of text items of x
set AppleScript's text item delimiters to oldDelims
{scount, chr5, id5, ccount}
--> {9, "
", {13, 10}, 1}
I don't see any bug there.
Despite its godlike publishing status, there's also bugs in the Henle
editions of the Chopin Mazurkas. Not many people notice them. But that
doesn't mean they don't exist. The bug is that CRLF is treated as one
(composite) character. Otherwise 'id of character 5 of x' would return
only 13, not a list. The CR and LF were deliberately set to Unicode
text separately in order to illustrate the problem.
This is exactly the same as Shane's. As you'd expect since 'as
Unicode text' does nothing in Leopard - all those strings and
characters are Unicode text already. (return as Unicode text) &
(linefeed as Unicode text) combine to make one CrLf character, as
Shane said - only one line break, not two; only one character, not
two.
Philip Aker
echo email@hidden@nl | tr a-z@. p-za-o.@
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden