[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Hackers corner: A sed script for decoding quoted printable
Last night I was setting up an emailable archive server on my home system
(servicemail makes some things so easy). The fact that it insists on returning
files in quoted printable or base64 is a compatibility problem since most
people don't have either. So, as the first stage in boostrapping users
to being able to decode these files the following was written. The next
step is leaving a standalone copy of the mimencode source on the server.
Nathaniel, I offer this up to the contrib part of the metamail distribution.
It misses the octets from =80 to =FF. It has been tested to properly
decode all the files on my archive server and doesn't crap out when the
original text has a trailing equal-sign (=). Since it has some control
characters I'll include a uuencoded version as well.
USAGE: sed -f qpdecode.sed <input >output
: top
s/=01//g
s/=02//g
s/=03//g
s/=04//g
s/=05//g
s/=06//g
s/=07//g
s/=08//g
s/=09/ /g
s/=0[aA]/\
/g
s/=0[bB]//g
s/=0[cC]//g
s/=0[dD]//g
s/=0[eE]//g
s/=0[fF]//g
s/=10//g
s/=11//g
s/=12//g
s/=13//g
s/=14//g
s/=15//g
s/=16//g
s/=17//g
s/=18//g
s/=19//g
s/=1[aA]//g
s/=1[bB]//g
s/=1[cC]//g
s/=1[dD]//g
s/=1[eE]//g
s/=1[fF]//g
s/=2[eE]/./g
/=$/{
N
s/=\n//g
b top
}
s/=3[dD]/=/g
begin 644 qpdecode.sed
M.B!T;W *<R\],#$O 2]G"G,O/3 R+P(O9PIS+STP,R\#+V<*<R\],#0O!"]G
M"G,O/3 U+P4O9PIS+STP-B\&+V<*<R\],#<O!R]G"G,O/3 X+P@O9PIS+STP
M.2\)+V<*<R\],%MA05TO7 HO9PIS+STP6V)"72\++V<*<R\],%MC0UTO#"]G
M"G,O/3!;9$1=+PTO9PIS+STP6V5%72\.+V<*<R\],%MF1ETO#R]G"G,O/3$P
M+Q O9PIS+STQ,2\1+V<*<R\],3(O$B]G"G,O/3$S+Q,O9PIS+STQ-"\4+V<*
M<R\],34O%2]G"G,O/3$V+Q8O9PIS+STQ-R\7+V<*<R\],3@O&"]G"G,O/3$Y
M+QDO9PIS+STQ6V%!72\:+V<*<R\],5MB0ETO&R]G"G,O/3%;8T-=+QPO9PIS
M+STQ6V1$72\=+V<*<R\],5ME15TO'B]G"G,O/3%;9D9=+Q\O9PIS+STR6V5%
M72\N+V<*+STD+WL*"4X*"7,O/5QN+R]G"@EB('1O< I]"G,O/3-;9$1=+STO
"9PHN
end