<<< Date Index >>>     <<< Thread Index >>>

Re: Message-hook problem



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday, August 20 at 07:40 AM, quoth Breen Mullins:
> * Kyle Wheeler <kyle-mutt@xxxxxxxxxxxxxx> [2007-08-20 07:42 
> -0600]:
>
>> On Sunday, August 19 at 12:41 PM, quoth Breen Mullins:
>>> I've wrestled with this one for a few days and I'm not getting 
>>> anywhere.
>>> It should be simple (and probably is!) but I'm not seeing it.
>>
>> Could you post an example message so that we can examine it?
>
> Sure. Here's a trimmed version, full thing available too.
> (I'm pretty sure I've got everything relevant...)

Aha! :)

It's pretty obvious when you think about it. Let me guess, you use a 
UTF-8 locale?

Mutt is converting the characters to be displayed (the 0xB9 in 
ISO-8859-1, which means a superscript 1) into the displayable 
characters (UTF-8). Thus the 0xB9 byte gets translated into 0xC2 0xB9, 
because that's what superscript-one is in UTF-8 (you notice how it's 
still got an 0xB9 in there?). The tr program, knowing only bytes, 
finds the 0xB9 byte and transforms it into 0x27, just like you told it 
to, leaving 0xC2 0x27. Because 0x27 does not fit the form 10zzzzzz, 
this is an invalid UTF-8 character, and so Mutt does its best to show 
it to you. (0xC2 == \302)

The tr program, unfortunately, does not understand UTF-8, so there's 
no truly "correct" way to use it to fix this problem. You can use this 
command:

     tr -s '\302\271' '\47'

And that will give you the correct output for this message, but will 
corrupt other messages that use UTF-8 characters also beginning with 
0xC2. The best way to fix this is with sed, rather than tr:

     sed "s/\o302\o271/'/g"

(That's for GNU sed; other sed's use different syntax for specifying 
bytes.)

~Kyle
- -- 
These are the times that try men's souls. The summer soldier and the 
sunshine patriot will, in this crisis, shrink from the service of 
their country; but he that stands it now, deserves the love and thanks 
of man and woman.
                                                        -- Thomas Paine
-----BEGIN PGP SIGNATURE-----
Comment: Thank you for using encryption!

iD8DBQFGybgzBkIOoMqOI14RAr9FAJ4j/zmFgeS9B6zSjtsu00R68/6ZrACgmVyn
Lrv3Pggc0Dn/1p1qYAGQqHA=
=8XeJ
-----END PGP SIGNATURE-----