31 #if defined (HAVE_CONFIG_H)
45 size_t srclen,
size_t *lengthp)
47 return u8_conv_from_encoding (fromcode, iconveh_question_mark,
48 src, srclen, NULL, NULL, lengthp);
52 octave_u8_conv_to_encoding_intern (
const char *tocode,
53 enum iconv_ilseq_handler handler,
54 const uint8_t *src,
size_t srclen,
55 size_t *offsets,
size_t *lengthp)
61 size_t padlen = (srclen > minlen ? srclen : minlen);
65 if ((tocode[0] !=
'u' && tocode[0] !=
'U')
66 || (tocode[1] !=
't' && tocode[1] !=
'T')
67 || (tocode[2] !=
'f' && tocode[2] !=
'F'))
70 uint8_t *u8_str = NULL;
71 const uint8_t *cu8_str;
74 u8_str = (uint8_t *)
malloc (padlen);
75 memcpy (u8_str, src, srclen);
76 for (
size_t i_pad = 0; i_pad < padlen-srclen; i_pad++)
77 u8_str[srclen+i_pad] = 0;
84 char *ret = u8_conv_to_encoding (tocode, handler, cu8_str, padlen,
85 offsets, NULL, lengthp);
88 free ((
void *) u8_str);
92 *lengthp = (*lengthp <= (padlen-srclen) ? 0 : *lengthp - (padlen-srclen));
99 size_t srclen,
size_t *lengthp)
101 return octave_u8_conv_to_encoding_intern (tocode, iconveh_question_mark,
102 src, srclen, NULL, lengthp);
107 size_t srclen,
size_t *lengthp)
109 return octave_u8_conv_to_encoding_intern (tocode, iconveh_error,
110 src, srclen, NULL, lengthp);
115 size_t srclen,
size_t *lengthp)
117 return u16_conv_from_encoding (fromcode, iconveh_question_mark,
118 src, srclen, NULL, NULL, lengthp);
123 size_t srclen,
size_t *lengthp)
125 return u16_conv_from_encoding (fromcode, iconveh_error,
126 src, srclen, NULL, NULL, lengthp);
131 size_t srclen,
size_t *lengthp)
133 return u16_conv_to_encoding (tocode, iconveh_question_mark,
134 src, srclen, NULL, NULL, lengthp);
139 size_t srclen,
size_t *lengthp)
141 return u16_conv_to_encoding (tocode, iconveh_error,
142 src, srclen, NULL, NULL, lengthp);
147 size_t srclen,
size_t *lengthp)
149 return u32_conv_to_encoding (tocode, iconveh_error,
150 src, srclen, NULL, NULL, lengthp);
155 (
const char *fromcode,
const char *src,
size_t srclen,
156 size_t *offsets,
size_t *lengthp)
158 return u8_conv_from_encoding (fromcode, iconveh_question_mark,
159 src, srclen, offsets, NULL, lengthp);
164 (
const char *tocode,
const uint8_t *src,
size_t srclen,
165 size_t *offsets,
size_t *lengthp)
167 return octave_u8_conv_to_encoding_intern (tocode, iconveh_question_mark,
168 src, srclen, offsets, lengthp);
177 size_t srclen = wcslen (wc) *
sizeof (wchar_t);
178 const char *src = (
const char *) wc;
181 uint8_t *mbchar = u8_conv_from_encoding (
"wchar_t", iconveh_question_mark,
182 src, srclen, NULL, NULL, &length);
185 char *retval =
malloc (length + 1);
188 memcpy (retval, mbchar, length);
189 free ((
void *) mbchar);
193 free ((
void *) mbchar);
204 size_t srclen =
strlen (u8);
205 const uint8_t *src = (
const uint8_t *) u8;
209 char *wchar = u8_conv_to_encoding (
"wchar_t", iconveh_question_mark,
210 src, srclen, NULL, NULL, &length);
212 wchar_t *retval =
malloc (length + 1 *
sizeof (
wchar_t));
215 memcpy (retval, wchar, length);
216 free ((
void *) wchar);
217 retval[length /
sizeof (wchar_t)] = 0;
221 free ((
void *) wchar);
T::size_type strlen(const typename T::value_type *str)
uint8_t * octave_u8_conv_from_encoding_offsets(const char *fromcode, const char *src, size_t srclen, size_t *offsets, size_t *lengthp)
char * octave_u8_conv_to_encoding_offsets(const char *tocode, const uint8_t *src, size_t srclen, size_t *offsets, size_t *lengthp)
uint16_t * octave_u16_conv_from_encoding(const char *fromcode, const char *src, size_t srclen, size_t *lengthp)
uint8_t * octave_u8_conv_from_encoding(const char *fromcode, const char *src, size_t srclen, size_t *lengthp)
char * octave_u32_conv_to_encoding_strict(const char *tocode, const uint32_t *src, size_t srclen, size_t *lengthp)
uint16_t * octave_u16_conv_from_encoding_strict(const char *fromcode, const char *src, size_t srclen, size_t *lengthp)
char * octave_u8_conv_to_encoding(const char *tocode, const uint8_t *src, size_t srclen, size_t *lengthp)
char * octave_u8_conv_to_encoding_strict(const char *tocode, const uint8_t *src, size_t srclen, size_t *lengthp)
wchar_t * u8_to_wchar(const char *u8)
char * octave_u16_conv_to_encoding(const char *tocode, const uint16_t *src, size_t srclen, size_t *lengthp)
char * octave_u16_conv_to_encoding_strict(const char *tocode, const uint16_t *src, size_t srclen, size_t *lengthp)
char * u8_from_wchar(const wchar_t *wc)