Added SILC Thread Queue API
[runtime.git] / apps / irssi / src / fe-common / core / utf8.h
1 #ifndef __UTF8_H
2 #define __UTF8_H
3
4 /* Returns -2 = invalid, -1 = need more data, otherwise unichar. */
5 int get_utf8_char(const unsigned char **ptr, int len, unichar *chr_r);
6
7 /* Returns length of UTF8 string */
8 int strlen_utf8(const char *str);
9
10 /* UTF-8 -> unichar string. The NUL is copied as well. */
11 void utf8_to_utf16(const char *str, unichar *out);
12
13 /* unichar -> UTF-8 string. outbuf must be at least 6 chars long.
14    Returns outbuf string length. */
15 int utf16_char_to_utf8(unichar c, char *outbuf);
16
17 /* unichar -> UTF-8 string. The NUL is copied as well.
18    Make sure out is at least 6 x length of str. */
19 void utf16_to_utf8(const unichar *str, char *out);
20
21 /* unichar -> UTF-8 string with position transformed. The NUL is copied as well.
22    Make sure out is at least 6 x length of str. */
23 void utf16_to_utf8_with_pos(const unichar *str, int spos, char *out, int *opos);
24
25 /* XXX I didn't check the encoding range of big5+. This is standard big5. */
26 #define is_big5_los(lo) (0x40 <= (lo) && (lo) <= 0x7E) /* standard */
27 #define is_big5_lox(lo) (0x80 <= (lo) && (lo) <= 0xFE) /* extended */
28 #define is_big5_lo(lo)  ((is_big5_los(lo) || is_big5_lox(lo)))
29 #define is_big5_hi(hi)  (0x81 <= (hi) && (hi) <= 0xFE)
30 #define is_big5(hi,lo) (is_big5_hi(hi) && is_big5_lo(lo))
31
32 /* Returns width for character (0-2). */
33 int utf8_width(unichar c);
34
35 #endif