2 * charset.h - header file for general character set conversion
6 #ifndef charset_charset_h
7 #define charset_charset_h
12 * Enumeration that lists all the multibyte or single-byte
13 * character sets known to this library.
16 CS_NONE, /* used for reporting errors, etc */
18 CS_ISO8859_1_X11, /* X font encoding with VT100 glyphs */
79 * Routine to convert a MB/SB character set to Unicode.
81 * This routine accepts some number of bytes, updates a state
82 * variable, and outputs some number of Unicode characters. There
83 * are no guarantees. You can't even guarantee that at most one
84 * Unicode character will be output per byte you feed in; for
85 * example, suppose you're reading UTF-8, you've seen E1 80, and
86 * then you suddenly see FE. Now you need to output _two_ error
87 * characters - one for the incomplete sequence E1 80, and one for
88 * the completely invalid UTF-8 byte FE.
90 * Returns the number of wide characters output; will never output
91 * more than the size of the buffer (as specified on input).
92 * Advances the `input' pointer and decrements `inlen', to indicate
93 * how far along the input string it got.
95 * The sequence of `errlen' wide characters pointed to by `errstr'
96 * will be used to indicate a conversion error. If `errstr' is
97 * NULL, `errlen' will be ignored, and the library will choose
98 * something sensible to do on its own. For Unicode, this will be
99 * U+FFFD (REPLACEMENT CHARACTER).
102 int charset_to_unicode(const char **input, int *inlen,
103 wchar_t *output, int outlen,
104 int charset, charset_state *state,
105 const wchar_t *errstr, int errlen);
108 * Routine to convert Unicode to an MB/SB character set.
110 * This routine accepts some number of Unicode characters, updates
111 * a state variable, and outputs some number of bytes.
113 * Returns the number of bytes characters output; will never output
114 * more than the size of the buffer (as specified on input), and
115 * will never output a partial MB character. Advances the `input'
116 * pointer and decrements `inlen', to indicate how far along the
117 * input string it got.
119 * The sequence of `errlen' characters pointed to by `errstr' will
120 * be used to indicate a conversion error. If `errstr' is NULL,
121 * `errlen' will be ignored, and the library will choose something
122 * sensible to do on its own (which will vary depending on the
126 int charset_from_unicode(const wchar_t **input, int *inlen,
127 char *output, int outlen,
128 int charset, charset_state *state,
129 const char *errstr, int errlen);
132 * Convert X11 encoding names to and from our charset identifiers.
134 const char *charset_to_xenc(int charset);
135 int charset_from_xenc(const char *name);
138 * Convert MIME encoding names to and from our charset identifiers.
140 const char *charset_to_mimeenc(int charset);
141 int charset_from_mimeenc(const char *name);
144 * Convert our own encoding names to and from our charset
147 const char *charset_to_localenc(int charset);
148 int charset_from_localenc(const char *name);
149 int charset_localenc_nth(int n);
152 * Convert Mac OS script/region/font to our charset identifiers.
154 int charset_from_macenc(int script, int region, int sysvers,
155 const char *fontname);
157 #endif /* charset_charset_h */