Strip high bit from text?

Chuck Swiger cswiger at mac.com
Wed Jul 21 23:03:53 UTC 2010


Hi, all--

On Jul 21, 2010, at 3:34 PM, David Kelly wrote:
> I regularly get email from a Blackberry user which my ISP then adds
> this header, "X-MIME-Autoconverted: from quoted-printable to 8bit". So
> far so good but the result always contains a number of 0xa0's in places
> a plain old space belongs. Mutt/vim renders these as "?" making a
> complete mess of things.

Those are Unicode/UTF-8 non-breaking-space characters, generally coming from HTML-formatted email.

> Already use procmail so adding an automatic filter should not be
> difficult if only I can come up with on.
> 
> Tried "tr \240 ' ' < testfile | hd" and was not able to change the 0xa0
> into anything. Have already spent much more time trying to make tr or
> sed do the job than it would have taken to knock something out in C, but
> I think there should be something laying around already in the base
> system to perform this task.
> 
> Suggestions? Repair the email while procmail has it? Reconfigure mutt and/or vim?

If you've got procmail in the loop already, then calling iconv  as a filter like so:

   iconv -f utf-8 -t ascii

...is likely to help.  Another choice would be to switch to using a MIME+Unicode/UTF-8 aware mail reader.

Regards,
-- 
-Chuck



More information about the freebsd-questions mailing list