]> mj.ucw.cz Git - libucw.git/blob - charset/charconv.h
14fee079ac02fea498c077bffcc55934c4a165e6
[libucw.git] / charset / charconv.h
1 /*
2  *      Character Set Conversion Library 1.0
3  *
4  *      (c) 1998 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
5  *
6  *      This software may be freely distributed and used according to the terms
7  *      of the GNU General Public License. See file COPYING in any of the GNU packages.
8  */
9
10 struct conv_context {
11
12   /* Parameters supplied by the caller */
13
14   const unsigned char *source;          /* Current position in source buffer */
15   const unsigned char *source_end;      /* End of source buffer */
16   unsigned char *dest;                  /* Current position in destination buffer */
17   unsigned char *dest_start;            /* First byte of destination buffer */
18   unsigned char *dest_end;              /* End of destination buffer */
19
20   /* Internal variables */
21
22   int (*convert)(struct conv_context *);
23   unsigned short int *in_to_x;
24   unsigned short int *x_to_out;
25   unsigned int state, value;
26 };
27
28 void conv_init(struct conv_context *);
29 void conv_set_charset(struct conv_context *, int, int);
30 #define conv_run(c) ((c)->convert(c))
31
32 #define CONV_SOURCE_END 1
33 #define CONV_DEST_END 2
34 #define CONV_SKIP 4
35
36 #define CONV_CHARSET_ASCII 0
37 #define CONV_CHARSET_LATIN1 1
38 #define CONV_CHARSET_LATIN2 2
39 #define CONV_CHARSET_UTF8 8
40 #define CONV_NUM_CHARSETS 9
41
42 int find_charset_by_name(char *);
43 char *charset_name(int);