On Friday 28 September 2007 11:17:09 Ronnie Gilkey wrote:
> I don't think that sed/sh is the answer.  I'd use Perl.  Basically you
> can write a smart regex to detect an equal sign followed by a hex code.
> The regex should capture the hex code.  From the trapped code, you could
> use the chr() function to replace the value (0x0a = newline):
>

Perl is probably a better solution, but I know sed better, so I wrote it using 
that.  The chr() function would be really be useful, though.  I'll have to 
look into changing my script to Perl, but for something quick and dirty, it 
solves the problem today.

Now the trick of integrating it into procmail as a filter, and still allowing 
other rules to process the mail later.

-- 
Thanks,
Fernando Vilas
fvilas at iname.com
-------------- next part --------------
#!/usr/bin/sed -f

# Join any lines ending in '=', then strip the "=\n"
:join 
/=$/ {
  N
  s/=\n//g
  b join
}

# Change "=96" to "-", since the ASCII value is really a u with a circumflex.
s/=96/-/g

# Change "=B4" to "'", since the ASCII value is really something else.
s/=B4/'/g

# Change other = codes to their ASCII values.
s/=09$/\t/g
s/=20$/ /g
s/=2D/-/g
s/=3D/=/g
s/=46/F/g
s/=5F/_/g

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : 
http://mail.brlug.net/pipermail/general_brlug.net/attachments/20070928/e917c22c/attachment.bin
 

Reply via email to