11/*
22 * Copyright (C) 1999-2002, 2004-2011, 2016, 2022-2023 Free Software Foundation, Inc.
3+ * Copyright (C) 2024 The C++ Project.
34 * This file is part of the cppp-reiconv library.
45 *
56 * The cppp-reiconv library is free software; you can redistribute it
1718 * If not, see <https://www.gnu.org/licenses/>.
1819 */
1920
20- /* This file defines all the converters. */
21+ #ifndef _CONVERTERS_H_
22+ #define _CONVERTERS_H_
2123
24+ #include "reiconv_defines.h"
2225
23- /* Our own notion of wide character, as UCS-4, according to ISO-10646-1. */
24- typedef unsigned int ucs4_t ;
25-
26- /* State used by a conversion. 0 denotes the initial state. */
27- typedef unsigned int state_t ;
28-
29- /* iconv_t is an opaque type. This is the real iconv_t type. */
30- typedef struct conv_struct * conv_t ;
31-
32- /*
33- * Data type for conversion multibyte -> unicode
34- */
35- struct mbtowc_funcs {
36- int (* xxx_mbtowc ) (conv_t conv , ucs4_t * pwc , unsigned char const * s , size_t n );
37- /*
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
44- * sequence was read,
45- * or RET_TOOFEW(number of bytes consumed) if only a shift sequence was read.
46- */
47- int (* xxx_flushwc ) (conv_t conv , ucs4_t * pwc );
48- /*
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.
52- */
53- };
54-
55- /* Return code if invalid input after a shift sequence of n bytes was read.
56- (xxx_mbtowc) */
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)
67-
68- /*
69- * Data type for conversion unicode -> multibyte
70- */
71- struct wctomb_funcs {
72- int (* xxx_wctomb ) (conv_t conv , unsigned char * r , ucs4_t wc , size_t n );
73- /*
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.
78- */
79- int (* xxx_reset ) (conv_t conv , unsigned char * r , size_t n );
80- /*
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.
85- */
86- };
87-
88- /* Return code if invalid. (xxx_wctomb) */
89- #define RET_ILUNI -1
90- /* Return code if output buffer is too small. (xxx_wctomb, xxx_reset) */
91- #define RET_TOOSMALL -2
92-
93- /*
94- * Contents of a conversion descriptor.
95- */
96- struct conv_struct {
97- struct loop_funcs lfuncs ;
98- /* Input (conversion multibyte -> unicode) */
99- int iindex ;
100- struct mbtowc_funcs ifuncs ;
101- state_t istate ;
102- /* Output (conversion unicode -> multibyte) */
103- int oindex ;
104- struct wctomb_funcs ofuncs ;
105- state_t ostate ;
106- /* Operation flags */
107- int discard_ilseq ;
108- };
109-
110- /*
111- * Include all the converters.
112- */
26+ // Include all the converters.
11327
11428#pragma region ASCII
11529#include "converters/ascii.h"
11630#pragma endregion
11731
11832#pragma region General multi-byte encodings
119- #include "converters/utf8.h"
33+ #include "converters/c99.h"
34+ #include "converters/java.h"
12035#include "converters/ucs2.h"
12136#include "converters/ucs2be.h"
37+ #include "converters/ucs2internal.h"
12238#include "converters/ucs2le.h"
39+ #include "converters/ucs2swapped.h"
12340#include "converters/ucs4.h"
12441#include "converters/ucs4be.h"
42+ #include "converters/ucs4internal.h"
12543#include "converters/ucs4le.h"
44+ #include "converters/ucs4swapped.h"
12645#include "converters/utf16.h"
12746#include "converters/utf16be.h"
12847#include "converters/utf16le.h"
12948#include "converters/utf32.h"
13049#include "converters/utf32be.h"
13150#include "converters/utf32le.h"
13251#include "converters/utf7.h"
133- #include "converters/ucs2internal.h"
134- #include "converters/ucs2swapped.h"
135- #include "converters/ucs4internal.h"
136- #include "converters/ucs4swapped.h"
137- #include "converters/c99.h"
138- #include "converters/java.h"
52+ #include "converters/utf8.h"
13953#pragma endregion
14054
14155#pragma region 8-bit encodings
142- #include "converters/iso8859_1.h"
143- #include "converters/iso8859_2.h"
144- #include "converters/iso8859_3.h"
145- #include "converters/iso8859_4.h"
146- #include "converters/iso8859_5.h"
147- #include "converters/iso8859_6.h"
148- #include "converters/iso8859_7.h"
149- #include "converters/iso8859_8.h"
150- #include "converters/iso8859_9.h"
151- #include "converters/iso8859_10.h"
152- #include "converters/iso8859_11.h"
153- #include "converters/iso8859_13.h"
154- #include "converters/iso8859_14.h"
155- #include "converters/iso8859_15.h"
156- #include "converters/iso8859_16.h"
157- #include "converters/koi8_r.h"
158- #include "converters/koi8_u.h"
159- #include "converters/koi8_ru.h"
56+ #include "converters/armscii_8.h"
57+ #include "converters/cp1131.h"
58+ #include "converters/cp1133.h"
16059#include "converters/cp1250.h"
16160#include "converters/cp1251.h"
16261#include "converters/cp1252.h"
@@ -169,39 +68,55 @@ struct conv_struct {
16968#include "converters/cp850.h"
17069#include "converters/cp862.h"
17170#include "converters/cp866.h"
172- #include "converters/cp1131.h"
173- #include "converters/mac_roman.h"
71+ #include "converters/cp874.h"
72+ #include "converters/georgian_academy.h"
73+ #include "converters/georgian_ps.h"
74+ #include "converters/hp_roman8.h"
75+ #include "converters/iso8859_1.h"
76+ #include "converters/iso8859_10.h"
77+ #include "converters/iso8859_11.h"
78+ #include "converters/iso8859_13.h"
79+ #include "converters/iso8859_14.h"
80+ #include "converters/iso8859_15.h"
81+ #include "converters/iso8859_16.h"
82+ #include "converters/iso8859_2.h"
83+ #include "converters/iso8859_3.h"
84+ #include "converters/iso8859_4.h"
85+ #include "converters/iso8859_5.h"
86+ #include "converters/iso8859_6.h"
87+ #include "converters/iso8859_7.h"
88+ #include "converters/iso8859_8.h"
89+ #include "converters/iso8859_9.h"
90+ #include "converters/koi8_r.h"
91+ #include "converters/koi8_ru.h"
92+ #include "converters/koi8_t.h"
93+ #include "converters/koi8_u.h"
94+ #include "converters/mac_arabic.h"
17495#include "converters/mac_centraleurope.h"
175- #include "converters/mac_iceland.h"
17696#include "converters/mac_croatian.h"
177- #include "converters/mac_romania.h"
17897#include "converters/mac_cyrillic.h"
179- #include "converters/mac_ukraine.h"
18098#include "converters/mac_greek.h"
181- #include "converters/mac_turkish.h"
18299#include "converters/mac_hebrew.h"
183- #include "converters/mac_arabic.h"
100+ #include "converters/mac_iceland.h"
101+ #include "converters/mac_roman.h"
102+ #include "converters/mac_romania.h"
184103#include "converters/mac_thai.h"
185- #include "converters/hp_roman8.h"
104+ #include "converters/mac_turkish.h"
105+ #include "converters/mac_ukraine.h"
106+ #include "converters/mulelao.h"
186107#include "converters/nextstep.h"
187- #include "converters/armscii_8.h"
188- #include "converters/georgian_academy.h"
189- #include "converters/georgian_ps.h"
190- #include "converters/koi8_t.h"
191108#include "converters/pt154.h"
192109#include "converters/rk1048.h"
193- #include "converters/mulelao.h"
194- #include "converters/cp1133.h"
110+ #include "converters/tcvn.h"
195111#include "converters/tis620.h"
196- #include "converters/cp874.h"
197112#include "converters/viscii.h"
198- #include "converters/tcvn.h"
199113#pragma endregion
200114
201115/* [CCS = coded character set] [CJKV.INF chapter 3] */
202- typedef struct {
203- unsigned short indx ; /* Index into big table. */
204- unsigned short used ; /* Bitmask of used entries. */
116+ typedef struct
117+ {
118+ unsigned short indx ; /* Index into big table. */
119+ unsigned short used ; /* Bitmask of used entries. */
205120} Summary16 ;
206121
207122#pragma region CJK character sets
@@ -210,64 +125,65 @@ typedef struct {
210125#include "converters/jisx0208.h"
211126#include "converters/jisx0212.h"
212127
213- #include "converters/iso646_cn.h"
214128#include "converters/gb2312.h"
129+ #include "converters/iso646_cn.h"
215130#include "converters/isoir165.h"
216131/* #include "converters/gb12345.h" */
217- #include "converters/gbk.h"
218- #include "converters/cns11643.h"
219132#include "converters/big5.h"
133+ #include "converters/cns11643.h"
134+ #include "converters/gbk.h"
220135
221- #include "converters/ksc5601.h"
222136#include "converters/johab_hangul.h"
137+ #include "converters/ksc5601.h"
223138#pragma endregion
224139
225140/* [CES = character encoding scheme] [CJKV.INF chapter 4] */
226141#pragma region CJK encodings
227- #include "converters/euc_jp.h"
228- #include "converters/sjis.h"
229142#include "converters/cp932.h"
143+ #include "converters/euc_jp.h"
230144#include "converters/iso2022_jp.h"
231145#include "converters/iso2022_jp1.h"
232146#include "converters/iso2022_jp2.h"
233147#include "converters/iso2022_jpms.h"
148+ #include "converters/sjis.h"
234149
235- #include "converters/euc_cn.h"
150+ #include "converters/big5hkscs1999.h"
151+ #include "converters/big5hkscs2001.h"
152+ #include "converters/big5hkscs2004.h"
153+ #include "converters/big5hkscs2008.h"
154+ #include "converters/ces_big5.h"
236155#include "converters/ces_gbk.h"
237156#include "converters/cp936.h"
157+ #include "converters/cp950.h"
158+ #include "converters/euc_cn.h"
159+ #include "converters/euc_tw.h"
238160#include "converters/gb18030_2005.h"
239161#include "converters/gb18030_2022.h"
162+ #include "converters/hz.h"
240163#include "converters/iso2022_cn.h"
241164#include "converters/iso2022_cnext.h"
242- #include "converters/hz.h"
243- #include "converters/euc_tw.h"
244- #include "converters/ces_big5.h"
245- #include "converters/cp950.h"
246- #include "converters/big5hkscs1999.h"
247- #include "converters/big5hkscs2001.h"
248- #include "converters/big5hkscs2004.h"
249- #include "converters/big5hkscs2008.h"
250165
251- #include "converters/euc_kr.h"
252166#include "converters/cp949.h"
253- #include "converters/johab .h"
167+ #include "converters/euc_kr .h"
254168#include "converters/iso2022_kr.h"
169+ #include "converters/johab.h"
255170
256- #include "converters/dec_kanji.h"
257171#include "converters/dec_hanyu.h"
172+ #include "converters/dec_kanji.h"
258173#pragma endregion
259174
260175#pragma region Encodings used by system dependent locales
261- #include "converters/cp856.h"
262- #include "converters/cp922.h"
263- #include "converters/cp943.h"
264176#include "converters/cp1046.h"
265177#include "converters/cp1124.h"
266178#include "converters/cp1129.h"
267179#include "converters/cp1161.h"
268180#include "converters/cp1162.h"
269181#include "converters/cp1163.h"
182+ #include "converters/cp856.h"
183+ #include "converters/cp922.h"
184+ #include "converters/cp943.h"
270185
186+ #include "converters/cp1125.h"
271187#include "converters/cp437.h"
272188#include "converters/cp737.h"
273189#include "converters/cp775.h"
@@ -282,7 +198,6 @@ typedef struct {
282198#include "converters/cp864.h"
283199#include "converters/cp865.h"
284200#include "converters/cp869.h"
285- #include "converters/cp1125.h"
286201#pragma endregion
287202
288203#define DEDUPLICATE_TABLES 1
@@ -344,11 +259,13 @@ typedef struct {
344259#pragma endregion
345260
346261#pragma region Extra encodings
262+ #include "converters/atarist.h"
263+ #include "converters/big5_2003.h"
347264#include "converters/euc_jisx0213.h"
348- #include "converters/shift_jisx0213.h"
349265#include "converters/iso2022_jp3.h"
350- #include "converters/big5_2003.h"
351- #include "converters/tds565.h"
352- #include "converters/atarist.h"
353266#include "converters/riscos1.h"
267+ #include "converters/shift_jisx0213.h"
268+ #include "converters/tds565.h"
354269#pragma endregion
270+
271+ #endif /* _CONVERTERS_H_ */
0 commit comments