That's where stringByReplacingPercentEscapesUsingEncoding: should help. Anyway, here's an updated version of the last script, dealing with both utf-8 and iso-8859-1 encoding:
use scripting additions
use framework "Foundation"
tell application id "com.apple.mail" -- Mail.app
set theSource to source of item 1 of (get selection)
end tell
-- extract first quoted printable section; this could also be done using TIDs or regular expressions
-- make into NSString
set source_s to current application's NSString's stringWithString:theSource
-- start by getting beginning
set headerStartRange to source_s's rangeOfString:(linefeed & "Content-Transfer-Encoding: quoted-printable")
-- boundary string should be preceding paragraph
set theBoundaryRange to source_s's paragraphRangeForRange:(current application's NSMakeRange((headerStartRange's location) - 1, 0))
set theBoundaryString to source_s's substringWithRange:theBoundaryRange
-- find next instance of boundary string to define end of part
set nextBoundaryRange to source_s's rangeOfString:theBoundaryString options:0 range:{current application's NSMaxRange(theBoundaryRange), (source_s's |length|()) - (current application's NSMaxRange(theBoundaryRange))}
-- skip first couple of lines (Content-Type: header)
set contentStartRange to source_s's rangeOfString:(linefeed & linefeed) options:0 range:{current application's NSMaxRange(headerStartRange), (source_s's |length|()) - (current application's NSMaxRange(headerStartRange))}
-- extract range of header text
set headers_s to source_s's substringWithRange:{current application's NSMaxRange(headerStartRange), (contentStartRange's location) - (current application's NSMaxRange(headerStartRange))}
-- get encoding
set encodingRange to headers_s's rangeOfString:"charset=\\S+" options:(current application's NSRegularExpressionSearch)
set theEncoding to headers_s's substringWithRange:{(encodingRange's location) + 8, (encodingRange's |length|()) - 8}
if (theEncoding's isEqualToString:"iso-8859-1") as boolean then
set theEncoding to current application's NSISOLatin1StringEncoding
else
set theEncoding to current application's NSUTF8StringEncoding
end if
-- extract range of text
set text_s to source_s's substringWithRange:{current application's NSMaxRange(contentStartRange), (nextBoundaryRange's location) - (current application's NSMaxRange(contentStartRange)) - 1}
-- get rid of QP = new lines; some mailers use CRLF, others LF only
set text_s to text_s's stringByReplacingOccurrencesOfString:("=" & return & linefeed) withString:""
set text_s to text_s's stringByReplacingOccurrencesOfString:("=" & linefeed) withString:""
-- temporarily replace any coded = signs
set text_s to text_s's stringByReplacingOccurrencesOfString:"=3D" withString:"%%%%%%"
-- replace = with %
set text_s to text_s's stringByReplacingOccurrencesOfString:"=" withString:"%"
-- put back = signs
set text_s to text_s's stringByReplacingOccurrencesOfString:"%%%%%%" withString:"="
--decode
set text_s to text_s's stringByReplacingPercentEscapesUsingEncoding:theEncoding
return text_s as text