• 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 to plain text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unicode to plain text


  • Subject: Re: Unicode to plain text
  • From: John Delacour <email@hidden>
  • Date: Thu, 19 Sep 2002 10:34:09 +0100

At 3:14 pm -0700 18/9/02, Jon Pugh wrote:

At 12:02 PM -0700 9/18/02, Jon Pugh wrote:
Does anyone know how to convert utxt to TEXT in plain AppleScript?

And the winner is:

At 2:04 PM -0700 9/18/02, John Coelho wrote:
>set plain_text to +class ktxt; of (unicodeString as record)

Thank you.

Thank you indeed! This solves what I too was beginning to think was insoluble.

To get the text of a plain text message in Eudora, one does:

set s to body of message 1

To do the same thing in Mail, here's the very shortest way:

tell app "Mail"
set s to the content of the first item of (get the selection)
end
if class of s is Unicode text then set s to Gclass ktxtH of (s as record)


Dontcha love this new 'English-like' AS everyone is talking about :-)

JD


PS.

Chris N. This clears up the little difficulty with the script I sent you with the UTF7 stuff. You'll find that this script will now give you the message without the garbage at the end:



(* Display a UTF-7 encoded Mail message as Unicode in TextEdit *)
set {d, tmp} to {current date, path to temporary items}
set n to d - (get date (("1/1/" & (d's year) + 1)))
set f to "" & tmp & "MAIL" & n & ".txt"
set {Ocode, Ucode, Usig} to {"unicode-2-0-utf-7", "unicode-2-0", "~"}
tell app "Mail"
set s to the content of the first item of (get the selection)
end
if class of s is Unicode text then set s to Gclass ktxtH of (s as record)
set s to TECConvertText s fromCode Ocode toCode Ucode
open for access file f with write permission
write Usig to file f
write s to file f
close access file f
tell app "Finder"
open file f using application file id "com.apple.textedit"
end
tell app "TextEdit" to activate


-- JD
_______________________________________________
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: Unicode to plain text ( funklessly )
      • From: Paul Skinner <email@hidden>
    • Re: Unicode to plain text
      • From: Mr Tea <email@hidden>
References: 
 >Unicode to plain text (From: Jon Pugh <email@hidden>)
 >Re: Unicode to plain text (From: Jon Pugh <email@hidden>)

  • Prev by Date: Re: FMP 6.0v3, OS X 10.2 and AppleScript -> Broken
  • Next by Date: Re: Unicode to plain text
  • Previous by thread: Re: Unicode to plain text
  • Next by thread: Re: Unicode to plain text
  • Index(es):
    • Date
    • Thread