1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* Conversions between Unicode and legacy encodings.
3 Copyright (C) 2002, 2005, 2007, 2009-2014 Free Software Foundation, Inc.
5 This program is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Lesser General Public License as published
7 by the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
26 /* Get enum iconv_ilseq_handler. */
27 #include <unistring/iconveh.h>
29 /* Get locale_charset() declaration. */
30 #include <unistring/localcharset.h>
38 /* Converts an entire string, possibly including NUL bytes, from one encoding
39 to a Unicode encoding.
40 Converts a memory region given in encoding FROMCODE. FROMCODE is as for
42 The input is in the memory region between SRC (inclusive) and SRC + SRCLEN
44 If OFFSETS is not NULL, it should point to an array of SRCLEN integers; this
45 array is filled with offsets into the result, i.e. the character starting
46 at SRC[i] corresponds to the character starting at (*RESULTP)[OFFSETS[i]],
47 and other offsets are set to (size_t)(-1).
48 RESULTBUF and *LENGTHP should initially be a scratch buffer and its size,
49 or *RESULTBUF can be NULL.
50 May erase the contents of the memory at RESULTBUF.
51 If successful: The resulting Unicode string (non-NULL) is returned and its
52 length stored in *LENGTHP. The resulting string is RESULTBUF if no dynamic
53 memory allocation was necessary, or a freshly allocated memory block
55 In case of error: NULL is returned and errno is set. Particular errno
56 values: EINVAL, EILSEQ, ENOMEM. */
58 u8_conv_from_encoding (const char *fromcode,
59 enum iconv_ilseq_handler handler,
60 const char *src, size_t srclen,
62 uint8_t *resultbuf, size_t *lengthp);
64 u16_conv_from_encoding (const char *fromcode,
65 enum iconv_ilseq_handler handler,
66 const char *src, size_t srclen,
68 uint16_t *resultbuf, size_t *lengthp);
70 u32_conv_from_encoding (const char *fromcode,
71 enum iconv_ilseq_handler handler,
72 const char *src, size_t srclen,
74 uint32_t *resultbuf, size_t *lengthp);
76 /* Converts an entire Unicode string, possibly including NUL units, from a
77 Unicode encoding to a given encoding.
78 Converts a memory region to encoding TOCODE. TOCODE is as for
80 The input is in the memory region between SRC (inclusive) and SRC + SRCLEN
82 If OFFSETS is not NULL, it should point to an array of SRCLEN integers; this
83 array is filled with offsets into the result, i.e. the character starting
84 at SRC[i] corresponds to the character starting at (*RESULTP)[OFFSETS[i]],
85 and other offsets are set to (size_t)(-1).
86 RESULTBUF and *LENGTHP should initially be a scratch buffer and its size,
87 or RESULTBUF can be NULL.
88 May erase the contents of the memory at RESULTBUF.
89 If successful: The resulting string (non-NULL) is returned and its length
90 stored in *LENGTHP. The resulting string is RESULTBUF if no dynamic memory
91 allocation was necessary, or a freshly allocated memory block otherwise.
92 In case of error: NULL is returned and errno is set. Particular errno
93 values: EINVAL, EILSEQ, ENOMEM. */
95 u8_conv_to_encoding (const char *tocode,
96 enum iconv_ilseq_handler handler,
97 const uint8_t *src, size_t srclen,
99 char *resultbuf, size_t *lengthp);
101 u16_conv_to_encoding (const char *tocode,
102 enum iconv_ilseq_handler handler,
103 const uint16_t *src, size_t srclen,
105 char *resultbuf, size_t *lengthp);
107 u32_conv_to_encoding (const char *tocode,
108 enum iconv_ilseq_handler handler,
109 const uint32_t *src, size_t srclen,
111 char *resultbuf, size_t *lengthp);
113 /* Converts a NUL terminated string from a given encoding.
114 The result is malloc allocated, or NULL (with errno set) in case of error.
115 Particular errno values: EILSEQ, ENOMEM. */
117 u8_strconv_from_encoding (const char *string,
118 const char *fromcode,
119 enum iconv_ilseq_handler handler);
121 u16_strconv_from_encoding (const char *string,
122 const char *fromcode,
123 enum iconv_ilseq_handler handler);
125 u32_strconv_from_encoding (const char *string,
126 const char *fromcode,
127 enum iconv_ilseq_handler handler);
129 /* Converts a NUL terminated string to a given encoding.
130 The result is malloc allocated, or NULL (with errno set) in case of error.
131 Particular errno values: EILSEQ, ENOMEM. */
133 u8_strconv_to_encoding (const uint8_t *string,
135 enum iconv_ilseq_handler handler);
137 u16_strconv_to_encoding (const uint16_t *string,
139 enum iconv_ilseq_handler handler);
141 u32_strconv_to_encoding (const uint32_t *string,
143 enum iconv_ilseq_handler handler);
145 /* Converts a NUL terminated string from the locale encoding.
146 The result is malloc allocated, or NULL (with errno set) in case of error.
147 Particular errno values: ENOMEM. */
149 u8_strconv_from_locale (const char *string);
151 u16_strconv_from_locale (const char *string);
153 u32_strconv_from_locale (const char *string);
155 /* Converts a NUL terminated string to the locale encoding.
156 The result is malloc allocated, or NULL (with errno set) in case of error.
157 Particular errno values: ENOMEM. */
159 u8_strconv_to_locale (const uint8_t *string);
161 u16_strconv_to_locale (const uint16_t *string);
163 u32_strconv_to_locale (const uint32_t *string);
170 #endif /* _UNICONV_H */