20cb8d8304a355bb05c47ea04639dcb2cd835415
[wimlib] / include / wimlib / encoding.h
1 #ifndef _WIMLIB_ENCODING_H
2 #define _WIMLIB_ENCODING_H
3
4 #include "wimlib/types.h"
5
6 extern void
7 iconv_global_cleanup(void);
8
9 extern void
10 init_upcase(void);
11
12 extern bool wimlib_mbs_is_utf8;
13
14 #define DECLARE_CHAR_CONVERSION_FUNCTIONS(varname1, varname2,           \
15                                           chartype1, chartype2)         \
16                                                                         \
17 extern int                                                              \
18 varname1##_to_##varname2(const chartype1 *in, size_t in_nbytes,         \
19                          chartype2 **out_ret,                           \
20                          size_t *out_nbytes_ret);                       \
21                                                                         \
22 extern int                                                              \
23 varname1##_to_##varname2##_nbytes(const chartype1 *in, size_t in_nbytes,\
24                                   size_t *out_nbytes_ret);              \
25                                                                         \
26 extern int                                                              \
27 varname1##_to_##varname2##_buf(const chartype1 *in, size_t in_nbytes,   \
28                                chartype2 *out);
29
30
31 #if !TCHAR_IS_UTF16LE
32 DECLARE_CHAR_CONVERSION_FUNCTIONS(utf16le, tstr, utf16lechar, tchar);
33 DECLARE_CHAR_CONVERSION_FUNCTIONS(tstr, utf16le, tchar, utf16lechar);
34 #endif
35
36 DECLARE_CHAR_CONVERSION_FUNCTIONS(utf8, tstr, char, tchar);
37 DECLARE_CHAR_CONVERSION_FUNCTIONS(tstr, utf8, tchar, char);
38
39 extern int
40 utf8_to_tstr_simple(const char *utf8str, tchar **out);
41
42 extern int
43 tstr_to_utf8_simple(const tchar *tstr, char **out);
44
45 extern int
46 cmp_utf16le_strings(const utf16lechar *s1, size_t n1,
47                     const utf16lechar *s2, size_t n2,
48                     bool ignore_case);
49
50 extern int
51 get_utf16le_string(const tchar *name, utf16lechar **name_utf16le_ret,
52                    u16 *name_utf16le_nbytes_ret);
53
54
55 #endif /* _WIMLIB_ENCODING_H */