• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Unicode text and the annoying relic called "styled text"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unicode text and the annoying relic called "styled text"


  • Subject: Re: Unicode text and the annoying relic called "styled text"
  • From: Paul Berkowitz <email@hidden>
  • Date: Wed, 22 Dec 2004 10:54:59 -0800

On 12/21/04 3:18 PM, "Scott Babcock" <email@hidden> wrote:

> Here's what I had to do to get what I wanted:
>
> set utxt to "Foo" as Unicode text
> set |TEXT| to utxt as string
> try
>     set styledText to |TEXT| as record
>     set |TEXT| to <<class ktxt>> of styledText
> end try
> set the clipboard to {string:|TEXT|, Unicode text:utxt}
>
> The attempt to coerce |TEXT| to a record will fail if it's not styled
> text, which is fine since that means that it's already a string. With
> the addition of the 'try' block, I seem to have a complete, albeit
> crufty, solution.
>  __________________

Thus is really ancient here, Scott. It's been hacked to death for centuries.
All you had to do was ask.

Here's the version I use, as first discovered/invented by Arthur Knapp:

on AsText(str)
    --coerce Unicode or other text to styled string to plain text
    try
        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



--
Paul Berkowitz


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Unicode text and the annoying relic called "styled text"
      • From: jj <email@hidden>
References: 
 >Unicode text and the annoying relic called "styled text" (From: "Scott Babcock" <email@hidden>)

  • Prev by Date: Re: Remote AppleEvents to older OS
  • Next by Date: Re: Unicode text and the annoying relic called "styled text"
  • Previous by thread: Re: Unicode text and the annoying relic called "styled text"
  • Next by thread: Re: Unicode text and the annoying relic called "styled text"
  • Index(es):
    • Date
    • Thread