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 6:40 AM, "Jim Trebilcock" <email@hidden> wrote:

>      This was an excellent suggestion, as was the one speculating that the
> problem was the use of the term "contents" instead of the preferred (in a
> handler) "content." However, neither suggestion solves the issue that anything
> taken from a text field or text view, even when coerced to "string," returns
> so-called bad characters, whereas straight vanilla AS strings do not return
> such characters.

This may be one of those cases where you need true blue plain text, not
merely 'string'. Coercing Unicode to string results in 'international'
styled text, which may still be considered "bad characters". Try this
instead:

set txtByline to (contents of "txtByline" of window "winStory")
set txtByline to my AsPlainText(txtByline) 


on AsPlainText(textual)
    
    (* Where 'textual' values may include plain text,'international text',
styled text, Pascal string, C string, Unicode text, and «class utf8».

    Unicode characters not having a single-byte "mapping" come back as a
question mark.
    *)
    
    set {text:plainText} to textual as text
    return plainText
    
end AsPlainText

-- 
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.