]> mj.ucw.cz Git - libucw.git/blob - charset/charconv.h
Fastbufs: Fixed uninitialized variables in fbmulti's structure.
[libucw.git] / charset / charconv.h
1 /*
2  *      Character Set Conversion Library 1.2
3  *
4  *      (c) 1998--2005 Martin Mares <mj@ucw.cz>
5  *      (c) 2007 Pavel Charvat <pchar@ucw.cz>
6  *
7  *      This software may be freely distributed and used according to the terms
8  *      of the GNU Lesser General Public License.
9  */
10
11 #ifndef _CHARSET_CHARCONV_H
12 #define _CHARSET_CHARCONV_H
13
14 #ifdef CONFIG_UCW_CLEAN_ABI
15 #define charset_name ucw_charset_name
16 #define conv_in_to_ucs ucw_conv_in_to_ucs
17 #define conv_init ucw_conv_init
18 #define conv_set_charset ucw_conv_set_charset
19 #define conv_ucs_to_out ucw_conv_ucs_to_out
20 #define conv_ucs_to_x ucw_conv_ucs_to_x
21 #define conv_x_count ucw_conv_x_count
22 #define conv_x_to_ucs ucw_conv_x_to_ucs
23 #define find_charset_by_name ucw_find_charset_by_name
24 #endif
25
26 struct conv_context {
27
28   /* Parameters supplied by the caller */
29
30   const unsigned char *source;          /* Current position in source buffer */
31   const unsigned char *source_end;      /* End of source buffer */
32   unsigned char *dest;                  /* Current position in destination buffer */
33   unsigned char *dest_start;            /* First byte of destination buffer */
34   unsigned char *dest_end;              /* End of destination buffer */
35
36   /* Internal variables */
37
38   int (*convert)(struct conv_context *);
39   int source_charset, dest_charset;
40   unsigned short int *in_to_x;
41   unsigned short int *x_to_out;
42   unsigned int state, code, remains;
43   unsigned char *string_at;
44 };
45
46 void conv_init(struct conv_context *);
47 void conv_set_charset(struct conv_context *, int, int);
48 #define conv_run(c) ((c)->convert(c))
49
50 #define CONV_SOURCE_END 1
51 #define CONV_DEST_END 2
52 #define CONV_SKIP 4
53
54 enum charset_id {
55         CONV_CHARSET_ASCII,
56         CONV_CHARSET_ISO_8859_1,
57         CONV_CHARSET_ISO_8859_2,
58         CONV_CHARSET_ISO_8859_3,
59         CONV_CHARSET_ISO_8859_4,
60         CONV_CHARSET_ISO_8859_5,
61         CONV_CHARSET_ISO_8859_6,
62         CONV_CHARSET_ISO_8859_7,
63         CONV_CHARSET_ISO_8859_8,
64         CONV_CHARSET_ISO_8859_9,
65         CONV_CHARSET_ISO_8859_10,
66         CONV_CHARSET_ISO_8859_11,
67         CONV_CHARSET_ISO_8859_13,
68         CONV_CHARSET_ISO_8859_14,
69         CONV_CHARSET_ISO_8859_15,
70         CONV_CHARSET_ISO_8859_16,
71         CONV_CHARSET_WIN1250,
72         CONV_CHARSET_WIN1251,
73         CONV_CHARSET_WIN1252,
74         CONV_CHARSET_KAMCS,
75         CONV_CHARSET_CSN369103,
76         CONV_CHARSET_CP852,
77         CONV_CHARSET_MACCE,
78         CONV_CHARSET_CORK,
79         CONV_CHARSET_UTF8,
80         CONV_CHARSET_UTF16_BE,
81         CONV_CHARSET_UTF16_LE,
82         CONV_NUM_CHARSETS
83 };
84
85 /* Conversion of a single character between current non-UTF8 charset and Unicode */
86 int conv_in_to_ucs(struct conv_context *c, unsigned int y);
87 int conv_ucs_to_out(struct conv_context *c, unsigned int ucs);
88
89 /* For those brave ones who want to mess with charconv internals */
90 unsigned int conv_x_to_ucs(unsigned int x);
91 unsigned int conv_ucs_to_x(unsigned int ucs);
92 unsigned int conv_x_count(void);
93
94 /* Charset names */
95
96 int find_charset_by_name(const char *);
97 char *charset_name(int);
98
99 #endif