Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'Bad' characters from AS Studio text fields



On 3/23/05 8:28 AM, "Jim Trebilcock" <email@hidden> wrote:

>  Many thanks Paul! Yes, that did the trick.
>  Question: Do I infer from your use of the handler that one can't directly
> coerce to text, e.g.,
> 
>     set txtByline to content of text field "txtByline" as text

You can coerce to text all you want - no error will result - but it will not
be _plain text_. It will be 'international' styled text if the original (as
in your case) was Unicode, styled text, etc. In AppleScript, 'text' and
'string' do not mean what most people think they mean - they do not mean
'plain text' - they cover most types of text except true Unicode. Styled
text can be represented by, and can be coerced to, a record, where one of
the record properties is indeed plain text, known confusingly as 'text'.
That's what the handler does. This handler is Arthur Knapp's. It's his final
version and gets around all sorts of peculiar hang-ups that simpler versions
hit (such as when the text is plain text to begin with, or certain true real
Unicode characters that do not coerce to styled text at all).

An earlier version of the handler makes the process a little clearer, but
does hit a few of those hang-ups, so don't use it:

on AsText(str)
    --corece Unicode or other text to styled string to plain text
    try
        --return (((str as string) as record)'s «class ktxt»)
        return (text of ((str as string) as record)) as string
    end try
    return str as string -- if plain text to begin with, or real Unicode
    
end AsText


If you look in the dictionary of a text editor like Tex-Edit Plus, you'll
see the various other record properties of styled text.
-- 
Paul Berkowitz


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden

References: 
 >Re: 'Bad' characters from AS Studio text fields (From: email@hidden (Jim Trebilcock))



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.