CS_ISO8859_16,
CS_CP437,
CS_CP850,
+ CS_CP852,
+ CS_CP866,
+ CS_CP874,
CS_CP1250,
CS_CP1251,
CS_CP1252,
CS_KOI8_R,
CS_KOI8_U,
CS_KOI8_RU,
+ CS_JISX0201,
CS_MAC_ROMAN,
CS_MAC_TURKISH,
CS_MAC_CROATIAN,
CS_SHIFT_JIS,
CS_HZ,
CS_CP949,
+ CS_PDF,
+ CS_PSSTD,
+ CS_CTEXT,
+ CS_ISO2022,
+ CS_BS4730,
+ CS_DEC_GRAPHICS,
+ CS_EUC_TW,
+ CS_LIMIT /* dummy value indicating extent of enum */
} charset_t;
typedef struct {
* NULL, `errlen' will be ignored, and the library will choose
* something sensible to do on its own. For Unicode, this will be
* U+FFFD (REPLACEMENT CHARACTER).
+ *
+ * `output' may be NULL, in which case the entire translation will
+ * be performed in theory (e.g. a dry run to work out how much
+ * space needs to be allocated for the real thing). `outlen' may
+ * also be negative, indicating an unlimited buffer length
+ * (although this is almost certainly unwise if `output' is _not_
+ * NULL).
*/
int charset_to_unicode(const char **input, int *inlen,
* If `input' is NULL, this routine will output the necessary bytes
* to reset the encoding state in any way which might be required
* at the end of an output piece of text.
+ *
+ * `output' may be NULL, in which case the entire translation will
+ * be performed in theory (e.g. a dry run to work out how much
+ * space needs to be allocated for the real thing). `outlen' may
+ * also be negative, indicating an unlimited buffer length
+ * (although this is almost certainly unwise if `output' is _not_
+ * NULL).
*/
int charset_from_unicode(const wchar_t **input, int *inlen,
const char *fontname);
/*
+ * Convert GNU Emacs coding system symbol to and from our charset
+ * identifiers.
+ */
+const char *charset_to_emacsenc(int charset);
+int charset_from_emacsenc(const char *name);
+
+/*
* Upgrade a charset identifier to a superset charset which is
* often confused with it. For example, people whose MUAs report
* their mail as ASCII or ISO8859-1 often in practice turn out to
*/
int charset_contains_ascii(int charset);
+/*
+ * This function tries to deduce the CS_* identifier of the charset
+ * used in the current C locale. It falls back to CS_ASCII if it
+ * can't figure it out at all, so it will always return a valid
+ * charset.
+ *
+ * (Note that you should have already called setlocale(LC_CTYPE,
+ * "") to guarantee that this function will do the right thing.)
+ */
+int charset_from_locale(void);
+
+/*
+ * This function simply reports whether a charset identifier
+ * corresponds to an actually usable charset. Not everything in the
+ * above enum does: CS_NONE, for a start, and occasionally other slots
+ * in the enum are reserved before they actually go into service.
+ *
+ * This function permits clients to iterate over _all_ supported
+ * charsets by means of a loop such as
+ *
+ * for (cs = 0; cs < CS_LIMIT; cs++)
+ * if (charset_exists(cs))
+ * do_stuff_with(cs);
+ */
+int charset_exists(int charset);
+
#endif /* charset_charset_h */