Re: Weird
Re: Weird
- Subject: Re: Weird
- From: Chris Espinosa <email@hidden>
- Date: Thu, 17 Oct 2002 12:11:17 -0700
On Thursday, October 17, 2002, at 11:00 AM, Paul Berkowitz
<email@hidden> wrote:
>
AS 1.9 in OS 10.2.1:
>
>
((ASCII character 32) as Unicode text) contains (ASCII character 202)
>
--> true
>
>
ASCII character 202 is the large option-space. ASCII character 32 is a
>
normal space.
>
>
I have a routine that checks for and removes option-spaces from
>
strings and
>
Unicode text. I discovered that every Unicode name (usually "firstName
>
lastName" with a space in between) was being tagged as "containing" an
>
option space and was sent to the handlers for removing it, but there
>
was
>
nothing to remove.
>
>
It turns out that the Unicode space between firstName and lastName
>
"contains" option-space, all by itself. I certainly hope this is a
>
bug. If
>
not, what exactly is it?
>
>
is there any AppleScript team person reading the list who can answer
>
this?
Yep.
Note that
(ASCII character 32) contains ((ASCII character 202) as Unicode
text)
is false.
The 'contains' operator does an equality comparison on each element of
the list or string in turn. As is usual with binary operators, the
right-hand operand is coerced to the same type as the left-hand operand
before the comparison.
So your expression compares two Unicode strings (the LHO being
explicitly coerced and the RHO being implicitly coerced). The latter
compares two ASCII strings.
One of two things is happening. Either the string-to-Unicode coercion
is promoting ASCII character 202 to the same Unicode character that
ASCII character 32 coerces to (so the space characters are in fact
identical, therefore one does contain the other); or the underlying
Unicode string comparison utilities that AppleScript uses are being
liberal and considering all spaces to be equal. That may not be what
you want in this particular circumstance, but in many other
circumstances, it is -- others may not want a script to fail when it's
looking for a space between two names just because it happens to be a
wider or thinner space than normal.
Chris
_______________________________________________
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.
- Follow-Ups:
- Re: Weird
- From: Bill Cheeseman <email@hidden>
- Re: Weird
- From: John Delacour <email@hidden>
- Re: Weird
- From: Paul Berkowitz <email@hidden>