Switch to autoconf 2.70.
[libiconv.git] / extras / iconv_string.h
blobfaab8c68bc97e931fd6e9667a12ef6d036b0c6a5
1 /* Copyright (C) 1999-2001 Bruno Haible.
2 This file is not part of the GNU LIBICONV Library.
3 This file is put into the public domain. */
5 /*
6 * This C function converts an entire string from one encoding to another,
7 * using iconv. Easier to use than iconv() itself, and supports autodetect
8 * encodings on input.
10 * int iconv_string (const char* tocode, const char* fromcode,
11 * const char* start, const char* end,
12 * char** resultp, size_t* lengthp)
14 * Converts a memory region given in encoding FROMCODE to a new memory
15 * region in encoding TOCODE. FROMCODE and TOCODE are as for iconv_open(3),
16 * except that FROMCODE may be one of the values
17 * "autodetect_utf8" supports ISO-8859-1 and UTF-8
18 * "autodetect_jp" supports EUC-JP, ISO-2022-JP-2 and SHIFT_JIS
19 * "autodetect_kr" supports EUC-KR and ISO-2022-KR
20 * The input is in the memory region between start (inclusive) and end
21 * (exclusive). If resultp is not NULL, the output string is stored in
22 * *resultp; malloc/realloc is used to allocate the result.
24 * This function does not treat zero characters specially.
26 * Return value: 0 if successful, otherwise -1 and errno set. Particular
27 * errno values: EILSEQ and ENOMEM.
29 * Example:
30 * const char* s = ...;
31 * char* result = NULL;
32 * if (iconv_string("UCS-4-INTERNAL", "autodetect_utf8",
33 * s, s+strlen(s)+1, &result, NULL) < 0)
34 * perror("iconv_string");
37 #include <stddef.h>
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
43 extern int iconv_string (const char* tocode, const char* fromcode, const char* start, const char* end, char** resultp, size_t* lengthp);
45 #ifdef __cplusplus
47 #endif