5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2004 - 2005 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
20 /****h* silcutil/SILC UTF-8 Interface
24 * Interface for the UTF-8 Unicode encoding form. These routines provides
25 * applications full UTF-8 and Unicode support. It supports UTF-8 encoding
26 * to and decoding from myriad of other character encodings.
33 /****f* silcutil/SilcUTF8API/silc_utf8_encode
37 * SilcUInt32 silc_utf8_encode(const unsigned char *bin, SilcUInt32 bin_len,
38 * SilcStringEncoding bin_encoding,
39 * unsigned char *utf8, SilcUInt32 utf8_size);
43 * Encodes the string `bin' of which encoding is `bin_encoding' to the
44 * UTF-8 encoding into the buffer `utf8' which is of size of `utf8_size'.
45 * Returns the length of the UTF-8 encoded string, or zero (0) on error.
46 * By default `bin_encoding' is ASCII, and the caller needs to know the
47 * encoding of the input string if it is anything else.
50 SilcUInt32 silc_utf8_encode(const unsigned char *bin, SilcUInt32 bin_len,
51 SilcStringEncoding bin_encoding,
52 unsigned char *utf8, SilcUInt32 utf8_size);
54 /****f* silcutil/SilcStrUtilAPI/silc_utf8_decode
58 * SilcUInt32 silc_utf8_decode(const unsigned char *utf8,
59 * SilcUInt32 utf8_len,
60 * SilcStringEncoding bin_encoding,
61 * unsigned char *bin, SilcUInt32 bin_size);
65 * Decodes UTF-8 encoded string `utf8' to string of which encoding is
66 * to be `bin_encoding', into the `bin' buffer of size of `bin_size'.
67 * Returns the length of the decoded buffer, or zero (0) on error.
68 * By default `bin_encoding' is ASCII, and the caller needs to know to
69 * which encoding the output string is to be encoded if ASCII is not
73 SilcUInt32 silc_utf8_decode(const unsigned char *utf8, SilcUInt32 utf8_len,
74 SilcStringEncoding bin_encoding,
75 unsigned char *bin, SilcUInt32 bin_size);
77 /****f* silcutil/SilcStrUtilAPI/silc_utf8_encoded_len
81 * SilcUInt32 silc_utf8_encoded_len(const unsigned char *bin,
83 * SilcStringEncoding bin_encoding);
87 * Returns the length of UTF-8 encoded string if the `bin' of
88 * encoding of `bin_encoding' is encoded with silc_utf8_encode.
89 * Returns zero (0) on error.
92 SilcUInt32 silc_utf8_encoded_len(const unsigned char *bin, SilcUInt32 bin_len,
93 SilcStringEncoding bin_encoding);
95 /****f* silcutil/SilcStrUtilAPI/silc_utf8_decoded_len
99 * SilcUInt32 silc_utf8_decoded_len(const unsigned char *bin,
100 * SilcUInt32 bin_len,
101 * SilcStringEncoding bin_encoding);
105 * Returns the length of decoded string if the `bin' of encoding of
106 * `bin_encoding' is decoded with silc_utf8_decode. Returns zero (0)
110 SilcUInt32 silc_utf8_decoded_len(const unsigned char *bin, SilcUInt32 bin_len,
111 SilcStringEncoding bin_encoding);
113 /****f* silcutil/SilcStrUtilAPI/silc_utf8_valid
117 * SilcBool silc_utf8_valid(const unsigned char *utf8, SilcUInt32 utf8_len);
121 * Returns TRUE if the `utf8' string of length of `utf8_len' is valid
122 * UTF-8 encoded string, FALSE if it is not UTF-8 encoded string.
125 SilcBool silc_utf8_valid(const unsigned char *utf8, SilcUInt32 utf8_len);
127 /****f* silcutil/SilcStrUtilAPI/silc_utf8_strcasecmp
131 * SilcBool silc_utf8_strcasecmp(const char *s1, const char *s2);
135 * The silc_utf8_strcasecmp() function compares the two strings s1 and s2,
136 * ignoring the case of the characters. It returns TRUE if the strings
137 * match and FALSE if they differ.
139 * This functions expects NULL terminated UTF-8 strings. The strings
140 * will be casefolded and normalized before comparing. Certain special
141 * Unicode characters will be ignored when comparing.
144 SilcBool silc_utf8_strcasecmp(const char *s1, const char *s2);
146 /****f* silcutil/SilcStrUtilAPI/silc_utf8_strncasecmp
150 * SilcBool silc_utf8_strcasecmp(const char *s1, const char *s2,
155 * The silc_utf8_strcasecmp() function compares the two strings s1 and s2,
156 * ignoring the case of the characters. It returns TRUE if the strings
157 * match and FALSE if they differ.
159 * This functions expects NULL terminated UTF-8 strings. The strings
160 * will be casefolded and normalized before comparing. Certain special
161 * Unicode characters will be ignored when comparing.
164 SilcBool silc_utf8_strncasecmp(const char *s1, const char *s2, SilcUInt32 n);
166 #endif /* SILCUTF8_H */