Edmund GRIMLEY EVANS writes:
> What options are there for obtaining the charset of the current locale
> from a shell script?
GNU nroff uses the following technique:
# First try the "locale charmap" command, because it's most reliable.
# On systems where it doesn't exist, look at the environment variables.
case "`locale charmap 2>/dev/null`" in
UTF-8) ...
*) case "${LC_ALL-${LC_CTYPE-${LANG}}}" in
*.UTF-8) ...
> If it doesn't already do so, perhaps the iconv command should have an
> option to tell you the charset of the current locale, as one of the
> most likely reasons for wanting to know it is in order to use it as an
> argument to iconv. So you could also have a pseudo-charset "locale",
> as in iconv -f locale -t utf-8.
A missing "-f" or "-t" argument to the iconv program already denotes
the locale charset. This is true for both glibc iconv (since
glibc-2.2.2) and libiconv iconv (since libiconv-1.6).
Bruno
-
Linux-UTF8: i18n of Linux on all levels
Archive: http://mail.nl.linux.org/linux-utf8/