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

Re: [Mutt] #3040: charset difference between index browser and pager



Hello Kyle,

 On Thursday, March 20, 2008 at 11:51:33 -0500, Kyle Wheeler wrote:

> On Thursday, March 20 at 03:47 PM, quoth Vincent Lefevre:
>> set charset=`codeset 2> /dev/null || locale charmap`//TRANSLIT
> it isn't particularly portable...

    While neither universally portable, there is a pair of alternatives.
First the Mutt-only, nice, but fails with non-recent Mutts, in UTF-8,
and on -HAVE_LANGINFO_CODESET systems:

| :set &charset my_charset="$charset//TRANSLIT" charset="$my_charset" 
&my_charset ?charset

    The other is using locale_charset() from libcharset, libiconv,
gettext, or whatever, and should be portable to a whole lot of systems.
Christian tested it OK on MacOS-X. Shouts canonical charset names even
on weird systems. Fails UTF-8. Needs to install the attached
locale_charset.c command.


> mutt makes the mistake of assuming that $charset is a good fall-back
> that will always be a valid MIME charset encoding name.

    The assumption is that when all normal mechanisms fail, there is
nothing more appropriate to do than send $charset unconverted. That's a
last resort fallback. It should not happen in a sane setup.

    If there is something better to do, then it should be done. For now,
I only see stripping //SUFFIXES from sent label. And validating the
charset settings of the user.


Bye!    Alain.
-- 
How to Report Bugs Effectively
<URL:http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>
/* Prints the portable name for the current locale's charset.
 * Build with gcc -o locale_charset locale_charset.c -lcharset
 * to catch /usr/local/lib/libcharset.so.1
 * Or -liconv to catch /usr/local/lib/libiconv.so.2
 * Or -lintl  to catch /usr/local/lib/libintl.so.2
 */

#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <localcharset.h>

int main ()
{
  setlocale(LC_ALL, "");
  printf("%s\n", locale_charset());
  exit(0);
}