• 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: Decoding Quoted-Printable in (Apple) Mail Message Source
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Decoding Quoted-Printable in (Apple) Mail Message Source


  • Subject: Re: Decoding Quoted-Printable in (Apple) Mail Message Source
  • From: Bob Stern <email@hidden>
  • Date: Sun, 19 Nov 2017 23:20:23 -0800

Here’s an old AppleScript I received from Allen Watson.  I don’t know whether
he’s the author or was merely forwarding it.  (Microsoft Entourage was the
predecessor of the Outlook email client for Mac.)

(*
Quoted printable is really a very simple encoding, just the hex value of higher
ASCII characters (>127)
http://www.mail-archive.com/email@hidden/msg08175.html
*)

on DecodeQP(aString)
        set HexChars to "0123456789ABCDEF"
        set oldDelims to AppleScript's text item delimiters
        set AppleScript's text item delimiters to {"="}
        set workList to text items of aString
        set returnValue to ""
        set firstOne to true
        repeat with s in workList
                if firstOne then
                        set firstOne to false
                        set returnValue to s
                else
                        if character 1 of s is return then set returnValue to
returnValue & s
                        try
                                set decNum to 0
                                set pair to characters 1 thru 2 of s
                                if item 1 of pair is not in HexChars or item 2
of pair is not in HexChars then
                                        set decNum to 0
                                else
                                        set decNum to ((offset of (item 1 of
pair) in HexChars) - 1) * 16 + ((offset of (item 2 of pair) in HexChars) - 1)
                                end if
                                if decNum ≠ 0 then
                                        set returnValue to returnValue & (ASCII
character decNum)
                                        if (length of s) ≥ 3 then
                                                set returnValue to returnValue
& text 3 thru -1 of s
--These 2 lines are erroneous:
                                                --else
                                                --      set returnValue to
returnValue & s
                                        end if
                                end if
                        on error errMsg number errNum from errFrom partial
result errResult to errTo
                                -- on error code goes here
                                display dialog errMsg & "Number:" & errNum
                                return
                        end try

                end if
        end repeat
        set AppleScript's text item delimiters to oldDelims
        return returnValue
end DecodeQP
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Decoding Quoted-Printable in (Apple) Mail Message Source
      • From: Christopher Stone <email@hidden>
    • Re: Decoding Quoted-Printable in (Apple) Mail Message Source
      • From: Shane Stanley <email@hidden>
References: 
 >Decoding Quoted-Printable in (Apple) Mail Message Source (From: Christopher Stone <email@hidden>)
 >Re: Decoding Quoted-Printable in (Apple) Mail Message Source (From: Takaaki Naganoya <email@hidden>)

  • Prev by Date: Re: Some help please
  • Next by Date: Re: Decoding Quoted-Printable in (Apple) Mail Message Source
  • Previous by thread: Re: Decoding Quoted-Printable in (Apple) Mail Message Source
  • Next by thread: Re: Decoding Quoted-Printable in (Apple) Mail Message Source
  • Index(es):
    • Date
    • Thread