]>
diplodocus.org Git - nmh/blob - sbr/check_charset.c
3 * check_charset.c -- routines for character sets
11 * Check if we can display a given character set natively.
12 * We are passed the length of the initial part of the
13 * string to check, since we want to allow the name of the
14 * character set to be a substring of a larger string.
18 check_charset (char *str
, int len
)
20 static char *mm_charset
= NULL
;
21 static char *alt_charset
= NULL
;
25 /* Cache the name of our default character set */
27 if (!(mm_charset
= getenv ("MM_CHARSET")))
28 mm_charset
= "US-ASCII";
29 mm_len
= strlen (mm_charset
);
31 /* US-ASCII is a subset of the ISO-8859-X character sets */
32 if (!strncasecmp("ISO-8859-", mm_charset
, 9)) {
33 alt_charset
= "US-ASCII";
34 alt_len
= strlen (alt_charset
);
38 /* Check if character set is OK */
39 if ((len
== mm_len
) && !strncasecmp(str
, mm_charset
, mm_len
))
41 if (alt_charset
&& (len
== alt_len
) && !strncasecmp(str
, alt_charset
, alt_len
))
49 * Return the name of the character set we are
50 * using for 8bit text.
53 write_charset_8bit (void)
55 static char *mm_charset
= NULL
;
58 * Cache the name of the character set to
61 if (!mm_charset
&& !(mm_charset
= getenv ("MM_CHARSET")))
62 mm_charset
= "x-unknown";