2 ** charset.c -- routines for character sets
4 ** This code is Copyright (c) 2002, by the authors of nmh. See the
5 ** COPYRIGHT file in the root directory of the nmh distribution for
6 ** complete copyright information.
10 #ifdef HAVE_LANGINFO_H
11 # include <langinfo.h>
16 ** Get the current character set
21 char *charset = getenv("MM_CHARSET");
22 #if defined(HAVE_NL_LANGINFO) && defined(CODESET)
24 charset = norm_charmap(nl_langinfo(CODESET));
32 ** Check if we can display a given character set natively.
35 is_native_charset(char *str)
37 char *mm_charset = NULL;
39 if (!(mm_charset = get_charset())) {
40 mm_charset = "US-ASCII";
42 if (mh_strcasecmp(str, mm_charset)==0) {
46 /* US-ASCII is a subset of the ISO-8859-X and UTF-8 character sets */
47 if (strncasecmp("ISO-8859-", mm_charset, 9)==0 ||
48 mh_strcasecmp("UTF-8", mm_charset)==0) {
49 if (mh_strcasecmp(str, "US-ASCII")==0) {
58 ** Return the name of the character set we are
59 ** using for 8bit text.
62 write_charset_8bit(void)
64 char *mm_charset = NULL;
66 if (!(mm_charset = get_charset())) {
67 mm_charset = "x-unknown";