2 * Copyright (C) 1999-2002, 2004-2011, 2016 Free Software Foundation, Inc.
3 * This file is part of the GNU LIBICONV Library.
5 * The GNU LIBICONV Library is free software; you can redistribute it
6 * and/or modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * The GNU LIBICONV Library is distributed in the hope that it will be
11 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with the GNU LIBICONV Library; see the file COPYING.LIB.
17 * If not, see <http://www.gnu.org/licenses/>.
20 /* This file defines all the converters. */
23 /* Our own notion of wide character, as UCS-4, according to ISO-10646-1. */
24 typedef unsigned int ucs4_t;
26 /* State used by a conversion. 0 denotes the initial state. */
27 typedef unsigned int state_t;
29 /* iconv_t is an opaque type. This is the real iconv_t type. */
30 typedef struct conv_struct * conv_t;
33 * Data type for conversion multibyte -> unicode
36 int (*xxx_mbtowc) (conv_t conv, ucs4_t *pwc, unsigned char const *s, size_t n);
38 * int xxx_mbtowc (conv_t conv, ucs4_t *pwc, unsigned char const *s, size_t n)
39 * converts the byte sequence starting at s to a wide character. Up to n bytes
40 * are available at s. n is >= 1.
41 * Result is number of bytes consumed (if a wide character was read),
42 * or -1 if invalid, or -2 if n too small,
43 * or RET_SHIFT_ILSEQ(number of bytes consumed) if invalid input after a shift
45 * or RET_TOOFEW(number of bytes consumed) if only a shift sequence was read.
47 int (*xxx_flushwc) (conv_t conv, ucs4_t *pwc);
49 * int xxx_flushwc (conv_t conv, ucs4_t *pwc)
50 * returns to the initial state and stores the pending wide character, if any.
51 * Result is 1 (if a wide character was read) or 0 if none was pending.
55 /* Return code if invalid input after a shift sequence of n bytes was read.
57 #define RET_SHIFT_ILSEQ(n) (-1-2*(n))
58 /* Return code if invalid. (xxx_mbtowc) */
59 #define RET_ILSEQ RET_SHIFT_ILSEQ(0)
60 /* Return code if only a shift sequence of n bytes was read. (xxx_mbtowc) */
61 #define RET_TOOFEW(n) (-2-2*(n))
62 /* Retrieve the n from the encoded RET_... value. */
63 #define DECODE_SHIFT_ILSEQ(r) ((unsigned int)(RET_SHIFT_ILSEQ(0) - (r)) / 2)
64 #define DECODE_TOOFEW(r) ((unsigned int)(RET_TOOFEW(0) - (r)) / 2)
65 /* Maximum value of n that may be used as argument to RET_SHIFT_ILSEQ or RET_TOOFEW. */
66 #define RET_COUNT_MAX ((INT_MAX / 2) - 1)
69 * Data type for conversion unicode -> multibyte
72 int (*xxx_wctomb) (conv_t conv, unsigned char *r, ucs4_t wc, size_t n);
74 * int xxx_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
75 * converts the wide character wc to the character set xxx, and stores the
76 * result beginning at r. Up to n bytes may be written at r. n is >= 1.
77 * Result is number of bytes written, or -1 if invalid, or -2 if n too small.
79 int (*xxx_reset) (conv_t conv, unsigned char *r, size_t n);
81 * int xxx_reset (conv_t conv, unsigned char *r, size_t n)
82 * stores a shift sequences returning to the initial state beginning at r.
83 * Up to n bytes may be written at r. n is >= 0.
84 * Result is number of bytes written, or -2 if n too small.
88 /* Return code if invalid. (xxx_wctomb) */
90 /* Return code if output buffer is too small. (xxx_wctomb, xxx_reset) */
91 #define RET_TOOSMALL -2
94 * Contents of a conversion descriptor.
97 struct loop_funcs lfuncs;
98 /* Input (conversion multibyte -> unicode) */
100 struct mbtowc_funcs ifuncs;
102 /* Output (conversion unicode -> multibyte) */
104 struct wctomb_funcs ofuncs;
107 /* Operation flags */
110 #ifndef LIBICONV_PLUG
111 struct iconv_fallbacks fallbacks;
112 struct iconv_hooks hooks;
117 * Include all the converters.
122 /* General multi-byte encodings */
137 #include "ucs2internal.h"
138 #include "ucs2swapped.h"
139 #include "ucs4internal.h"
140 #include "ucs4swapped.h"
144 /* 8-bit encodings */
145 #include "iso8859_1.h"
146 #include "iso8859_2.h"
147 #include "iso8859_3.h"
148 #include "iso8859_4.h"
149 #include "iso8859_5.h"
150 #include "iso8859_6.h"
151 #include "iso8859_7.h"
152 #include "iso8859_8.h"
153 #include "iso8859_9.h"
154 #include "iso8859_10.h"
155 #include "iso8859_11.h"
156 #include "iso8859_13.h"
157 #include "iso8859_14.h"
158 #include "iso8859_15.h"
159 #include "iso8859_16.h"
176 #include "mac_roman.h"
177 #include "mac_centraleurope.h"
178 #include "mac_iceland.h"
179 #include "mac_croatian.h"
180 #include "mac_romania.h"
181 #include "mac_cyrillic.h"
182 #include "mac_ukraine.h"
183 #include "mac_greek.h"
184 #include "mac_turkish.h"
185 #include "mac_hebrew.h"
186 #include "mac_arabic.h"
187 #include "mac_thai.h"
188 #include "hp_roman8.h"
189 #include "nextstep.h"
190 #include "armscii_8.h"
191 #include "georgian_academy.h"
192 #include "georgian_ps.h"
203 /* CJK character sets [CCS = coded character set] [CJKV.INF chapter 3] */
206 unsigned short indx; /* index into big table */
207 unsigned short used; /* bitmask of used entries */
210 #include "iso646_jp.h"
211 #include "jisx0201.h"
212 #include "jisx0208.h"
213 #include "jisx0212.h"
215 #include "iso646_cn.h"
217 #include "isoir165.h"
218 /*#include "gb12345.h"*/
220 #include "cns11643.h"
224 #include "johab_hangul.h"
226 /* CJK encodings [CES = character encoding scheme] [CJKV.INF chapter 4] */
231 #include "iso2022_jp.h"
232 #include "iso2022_jp1.h"
233 #include "iso2022_jp2.h"
234 #include "iso2022_jpms.h"
240 #include "iso2022_cn.h"
241 #include "iso2022_cnext.h"
244 #include "ces_big5.h"
246 #include "big5hkscs1999.h"
247 #include "big5hkscs2001.h"
248 #include "big5hkscs2004.h"
249 #include "big5hkscs2008.h"
254 #include "iso2022_kr.h"
256 /* Encodings used by system dependent locales. */
271 #include "dec_kanji.h"
272 #include "dec_hanyu.h"
294 #include "euc_jisx0213.h"
295 #include "shift_jisx0213.h"
296 #include "iso2022_jp3.h"
297 #include "big5_2003.h"