X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fstriconveh.h;h=1e833a053c075ba20813c3681451e6df87e17011;hb=4ad44dd748d5da39555cdf305568280d69a23354;hp=2ea7d540f0a0c34e92c1cfe3d78910462ac214a3;hpb=6984bc2a8dbe533274ee1869ba3c9e919040cf85;p=gnulib.git diff --git a/lib/striconveh.h b/lib/striconveh.h index 2ea7d540f..1e833a053 100644 --- a/lib/striconveh.h +++ b/lib/striconveh.h @@ -47,6 +47,10 @@ enum iconv_ilseq_handler (iconv_t)(-1) if FROM_CODESET is UTF-8). CD2 is the conversion descriptor from UTF-8 to TO_CODESET (or (iconv_t)(-1) if TO_CODESET is UTF-8). + If OFFSETS is not NULL, it should point to an array of SRCLEN integers; this + array is filled with offsets into the result, i.e. the character starting + at SRC[i] corresponds to the character starting at (*RESULTP)[OFFSETS[i]], + and other offsets are set to (size_t)(-1). *RESULTP and *LENGTH should initially be a scratch buffer and its size, or *RESULTP can initially be NULL. May erase the contents of the memory at *RESULTP. @@ -58,6 +62,7 @@ extern int mem_cd_iconveh (const char *src, size_t srclen, iconv_t cd, iconv_t cd1, iconv_t cd2, enum iconv_ilseq_handler handler, + size_t *offsets, char **resultp, size_t *lengthp); /* Convert an entire string from one encoding to another, using iconv. @@ -80,6 +85,26 @@ extern char * #endif /* Convert an entire string from one encoding to another, using iconv. + The original string is at [SRC,...,SRC+SRCLEN-1]. + If OFFSETS is not NULL, it should point to an array of SRCLEN integers; this + array is filled with offsets into the result, i.e. the character starting + at SRC[i] corresponds to the character starting at (*RESULTP)[OFFSETS[i]], + and other offsets are set to (size_t)(-1). + *RESULTP and *LENGTH should initially be a scratch buffer and its size, + or *RESULTP can initially be NULL. + May erase the contents of the memory at *RESULTP. + Return value: 0 if successful, otherwise -1 and errno set. + If successful: The resulting string is stored in *RESULTP and its length + in *LENGTHP. *RESULTP is set to a freshly allocated memory block, or is + unchanged if no dynamic memory allocation was necessary. */ +extern int + mem_iconveh (const char *src, size_t srclen, + const char *from_codeset, const char *to_codeset, + enum iconv_ilseq_handler handler, + size_t *offsets, + char **resultp, size_t *lengthp); + +/* Convert an entire string from one encoding to another, using iconv. The original string is the NUL-terminated string starting at SRC. Both the "from" and the "to" encoding must use a single NUL byte at the end of the string (i.e. not UCS-2, UCS-4, UTF-16, UTF-32).