Re: [Mutt] #3040: charset difference between index browser and pager
#3040: charset difference between index browser and pager
Comment (by Kyle Wheeler):
{{{
On Thursday, March 20 at 03:47 PM, quoth Vincent Lefevre:
>> Do not set $charset. There are very few good reasons for it.
>
> A good reason is to use transliteration!
I didn't say there were *NO* good reasons. Transliteration is the only
one I'm aware of, and even that has problems, as Alain pointed out.
>> There is *never* a good reason to use UTF-8 and //TRANSLIT at the
>> same time.
>
> Then, how would you write the following?
>
> set charset=`codeset 2> /dev/null || locale charmap`//TRANSLIT
Part of the problem there is that it isn't particularly portable... I
mean, neither `codeset` nor `locale charmap` do anything on my OSX
10.4.x box---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. Detecting the local characterset is more complicated...
for example, in an X11 environment, this often works:
xprop -id $WINDOWID -f WM_LOCALE_NAME 8s ' $0' -notype WM_LOCALE_NAME
... but not always.
The way I personally go about doing it is putting a fairly complicated
mechanism in my bashrc such that $LANG is a reliable variable (or at
least, as reliable as I can make it), and then I do things in my
muttrc based on that if needed.
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 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. This is an assumption on mutt's part, and it works
mostly by coincidence (aside from convention, there's no good reason
that the charset my terminal uses should be expected map to a valid
MIME charset name).
~Kyle
}}}
--
Ticket URL: <http://dev.mutt.org/trac/ticket/3040#comment:>