Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.string.quotedPrintableDecode
on quotedPrintableDecode (s) { <<3/1/01; 4:16:00 PM by JES <<Convert quoted printable text to ASCII text. <<Cribbed from contentServer.textCleaners.repairQP. <<Changes: <<3/1/01; 6:30:40 PM by JES <<Convert soft carriage returns to the empty sring. <<3/1/01; 7:21:30 PM by JES <<Optimization: let the kernel translate the hexidecimal number, instead of doing it in script code. local (ix = 1, ch, flhex = false, hexstring); on translateHexString (hexstring) { hexstring = "0x" + hexstring; return (char (number (hexstring)))}; bundle { //decode soft carriage returns s = string.replaceAll (s, "=\r\n", "")}; loop { ch = s [ix]; if flhex { if (ch >= 65 and ch <= 70) or string.isNumeric (ch) { //0-9, A-F hexstring = hexstring + ch; if sizeOf (hexstring) == 2 { s = string.replaceAll (s, "=" + hexstring, translateHexString (hexstring)); flhex = false; hexstring = ""; ix = ix - 2}} else { flhex = false}} else { if ch == '=' { flhex = true}}; ix++; if ix > sizeOf (s) { break}}; return (s)} <<bundle //test code <<string.quotedPrintableDecode ("Here's some more accented text: =E5=E9=EE=F8=FC=F1") //Windows <<"Here's some more accented text: åéîøüñ" <<string.latinToMac (string.quotedPrintableDecode ("Here's some more accented text: =E5=E9=EE=F8=FC=F1")) //Mac <<"Here's some more accented text: ŒŽ”¿Ÿ–"
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.