Paragraphs BUG
Paragraphs BUG
- Subject: Paragraphs BUG
- From: Paul Berkowitz <email@hidden>
- Date: Mon, 02 Sep 2002 18:14:25 -0700
Since about AS 1.6, or maybe earlier, we've been told that 'paragraphs' will
work whether the line endings are CR, LF, or CRLF.
Since AS 1.8.3, concatenations 'as Unicode text' have worked even when some
component parts are string (and behave as expected when those are MacRoman
strings). So you can do
(someUnicodeText & "a") as Unicode text
without having to do
(someUnicodeText & ("a" as Unicode text)) as Unicode text
The same applies to contacts such as return, tab and space.
Now look at this - AS 1.9, OS 10.2
property lf : (ASCII character 10)
property cr : return
property a : "a"
set p to (a & cr & a)
set q to (a & lf & a)
set r to p as Unicode text
set s to q as Unicode text
{count (paragraphs of p), count (paragraphs of q), count (paragraphs of r),
count (paragraphs of s)}
--> {2, 2, 2, 1}
This is absurd: LF is seen as a paragraph separator (line ending) in a
string, but not in Unicode text. And of course all the new OS X apps are
Unicode.
I was just hit by this in Address Book. It accepts Unicode text with CRs
imported from elsewhere, displays it just fine with line endings, lets me
get the text again and break it into paragraphs. But if I type a carriage
return with the keyboard and save, some of my line endings are now CRs and
some are LFs. When I get the text by AppleScript, and ask for paragraphs,
it's all wrong: even if I insert CRs between paragraphs set the resulting
text as Unicode, it carries the LFs within it and they are displayed as
boxes in Carbon apps.
It means I have to go back to extracting text items, replacing all LFs with
returns, then get paragraphs again, and finally do other manipulations
before setting it back as Unicode text.
This is _not_ good.
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.