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