This source file includes following definitions.
- FUNC
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 char *
26 FUNC (const UNIT *string,
27 const char *tocode,
28 enum iconv_ilseq_handler handler)
29 {
30 #if HAVE_UTF_NAME
31 char *result = NULL;
32 size_t length = 0;
33
34 if (mem_iconveha ((const char *) string, (U_STRLEN (string) + 1) * sizeof (UNIT),
35 UTF_NAME, tocode,
36 handler == iconveh_question_mark, handler,
37 NULL, &result, &length) < 0)
38 return NULL;
39
40 if (!(length > 0 && result[length-1] == '\0' && strlen (result) == length-1))
41 {
42 free (result);
43 errno = EILSEQ;
44 return NULL;
45 }
46 return result;
47 #else
48 uint8_t tmpbuf[4096];
49 size_t tmpbufsize = SIZEOF (tmpbuf);
50 uint8_t *utf8_string;
51 char *result;
52
53 utf8_string = U_TO_U8 (string, U_STRLEN (string) + 1, tmpbuf, &tmpbufsize);
54 if (utf8_string == NULL)
55 return NULL;
56 result = u8_strconv_to_encoding (utf8_string, tocode, handler);
57 if (result == NULL)
58 {
59 if (utf8_string != tmpbuf)
60 {
61 int saved_errno = errno;
62 free (utf8_string);
63 errno = saved_errno;
64 }
65 return NULL;
66 }
67 if (utf8_string != tmpbuf)
68 free (utf8_string);
69 return result;
70 #endif
71 }