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

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



#3040: charset difference between index browser and pager

Comment (by Vincent Lefevre):

 {{{
 On 2008-03-20 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
 >
 > Part of the problem there is that it isn't particularly portable...

 A .muttrc file doesn't have to be portable. It just needs to work
 on all the platforms I use, and this is the case.

 > I mean, neither `codeset` nor `locale charmap` do anything on my
 > OSX 10.4.x box

 "codeset" is a little C program I wrote because of the "locale charmap"
 bug on Mac OS X.

 > ---it doesn't have a "codeset" binary, and "locale charmap" isn't
 > something that conforms to the POSIX locale standard as far as I can
 > determine.

 "locale charmap" is specified by POSIX:

   http://www.opengroup.org/onlinepubs/009695399/utilities/locale.html

 The following operand shall be supported:

 name
     The name of a locale category as defined in the Base Definitions
     volume of IEEE Std 1003.1-2001, Chapter 7, Locale, the name of a
     keyword in a locale category, or the reserved name charmap. [...]
                                                        ^^^^^^^

 > Detecting the local characterset is more complicated...

 "locale charmap" should give it. Otherwise this means that the LC_*
 environment variables are not correctly set, hence many problems; so,
 the real fix is to fix them first.

 > But assuming that either `codeset` or `locale charmap` work for all the
 > machines you care about, and assuming your $SHELL is bash (so that it
 > recognizes the pattern matching), I would suggest something like this:
 >
 >     `charmap=$(codeset 2>/dev/null || locale charmap); \
 >     [[ $charmap =~ *UTF* || $charmap =~ *utf* ]] && \
 >     echo set my_mutt_autodetects_utf8="" || \
 >     echo set charset=$charmap//TRANSLIT`

 That's bloated and not portable ($SHELL is not always bash or
 something compatible with bash in my case).

 > That's just me. Then again, mutt makes the mistake of assuming that
 > $charset is a good fall-back that will always be a valid MIME charset
 > encoding name.

 That's a bug.
 }}}

-- 
Ticket URL: <http://dev.mutt.org/trac/ticket/3040#comment:>