]> mj.ucw.cz Git - libucw.git/blob - charset/charconv.h
Clarified a comment.
[libucw.git] / charset / charconv.h
1 /*
2  *      Character Set Conversion Library 1.2
3  *
4  *      (c) 1998--2004 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 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   int source_charset, dest_charset;
24   unsigned short int *in_to_x;
25   unsigned short int *x_to_out;
26   unsigned int state, code, remains;
27   unsigned char *string_at;
28 };
29
30 void conv_init(struct conv_context *);
31 void conv_set_charset(struct conv_context *, int, int);
32 #define conv_run(c) ((c)->convert(c))
33
34 #define CONV_SOURCE_END 1
35 #define CONV_DEST_END 2
36 #define CONV_SKIP 4
37
38 enum charset_id {
39         CONV_CHARSET_ASCII,
40         CONV_CHARSET_ISO_8859_1,
41         CONV_CHARSET_ISO_8859_2,
42         CONV_CHARSET_ISO_8859_3,
43         CONV_CHARSET_ISO_8859_4,
44         CONV_CHARSET_ISO_8859_5,
45         CONV_CHARSET_ISO_8859_6,
46         CONV_CHARSET_ISO_8859_7,
47         CONV_CHARSET_ISO_8859_8,
48         CONV_CHARSET_ISO_8859_9,
49         CONV_CHARSET_ISO_8859_10,
50         CONV_CHARSET_ISO_8859_11,
51         CONV_CHARSET_ISO_8859_13,
52         CONV_CHARSET_ISO_8859_14,
53         CONV_CHARSET_ISO_8859_15,
54         CONV_CHARSET_ISO_8859_16,
55         CONV_CHARSET_WIN1250,
56         CONV_CHARSET_WIN1252,
57         CONV_CHARSET_KAMCS,
58         CONV_CHARSET_CSN369103,
59         CONV_CHARSET_CP852,
60         CONV_CHARSET_MACCE,
61         CONV_CHARSET_CORK,
62         CONV_CHARSET_UTF8,
63         CONV_NUM_CHARSETS
64 };
65
66 /* Conversion of a single character between current non-UTF8 charset and Unicode */
67 int conv_in_to_ucs(struct conv_context *c, unsigned int y);
68 int conv_ucs_to_out(struct conv_context *c, unsigned int ucs);
69
70 /* For those brave ones who want to mess with charconv internals */
71 unsigned int conv_x_to_ucs(unsigned int x);
72 unsigned int conv_ucs_to_x(unsigned int ucs);
73 unsigned int conv_x_count(void);
74
75 /* Charset names */
76
77 int find_charset_by_name(char *);
78 char *charset_name(int);