Re: Can anyone explain this?
Re: Can anyone explain this?
- Subject: Re: Can anyone explain this?
- From: Paul Berkowitz <email@hidden>
- Date: Fri, 27 Dec 2002 13:34:19 -0800
On 12/27/02 12:50 PM, "Michelle Steiner" <email@hidden> wrote:
>
set foo to (choose file)
>
tell application "Finder" to set foo_name to name of foo
>
--> "Advance and Retreat"
>
>
text items of foo_name
>
--> {"", "", "d", "v", "a", "n", "c", "e", " ", "a", "n", "d", " ",
>
"R", "e", "t", "r", "e", "a", "t"}
>
>
The first text item is replaced by two null characters.
>
>
But
>
set foo_name to "Advance and Retreat"
>
text items of foo_name
>
--> {"A", "d", "v", "a", "n", "c", "e", " ", "a", "n", "d", " ", "R",
>
"e", "t", "r", "e", "a", "t"}
It should be fixed. But 'name' in the Finder is Unicode. This works as
you'd expect:
set foo to (choose file)
tell application "Finder" to set foo_name to name of foo as string
text items of foo_name
So does this, to get the Unicode version of the characters:
set foo to (choose file)
tell application "Finder" to set foo_name to name of foo
characters of foo_name
You never need {""} as tids: just use 'characters'.
I think there are some "interesting" coercions of string to Unicode and back
that allow us to use ASCII characters as text item delimiters without
specifying 'as Unicode text' every time we use them on Unicode strings.
That's very handy, especially for punctuation, return, etc. And I think
there's some odd sort of implementation whereby the '0' byte in Unicode gets
transmitted as "". Probably Unicode versions of ASCII text begin with two of
these, and they somehow get transmitted as such, one by one, before the
'code' is read as "This is Unicode" for later characters. Or something.
--
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.