1 /* -*- buffer-read-only: t -*- vi: set ro: */ 2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 3 /* Charset conversion. 4 Copyright (C) 2001-2004, 2006-2007, 2009-2010 Free Software Foundation, Inc. 5 Written by Bruno Haible and Simon Josefsson. 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 3, or (at your option) 10 any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software Foundation, 19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 20 21 #ifndef _STRICONV_H 22 #define _STRICONV_H 23 24 #include <stddef.h> 25 #if HAVE_ICONV 26 #include <iconv.h> 27 #endif 28 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 35 #if HAVE_ICONV 36 37 /* Convert an entire string from one encoding to another, using iconv. 38 The original string is at [SRC,...,SRC+SRCLEN-1]. 39 The conversion descriptor is passed as CD. 40 *RESULTP and *LENGTH should initially be a scratch buffer and its size, 41 or *RESULTP can initially be NULL. 42 May erase the contents of the memory at *RESULTP. 43 Return value: 0 if successful, otherwise -1 and errno set. 44 If successful: The resulting string is stored in *RESULTP and its length 45 in *LENGTHP. *RESULTP is set to a freshly allocated memory block, or is 46 unchanged if no dynamic memory allocation was necessary. */ 47 extern int mem_cd_iconv (const char *src, size_t srclen, iconv_t cd, 48 char **resultp, size_t *lengthp); 49 50 /* Convert an entire string from one encoding to another, using iconv. 51 The original string is the NUL-terminated string starting at SRC. 52 The conversion descriptor is passed as CD. Both the "from" and the "to" 53 encoding must use a single NUL byte at the end of the string (i.e. not 54 UCS-2, UCS-4, UTF-16, UTF-32). 55 Allocate a malloced memory block for the result. 56 Return value: the freshly allocated resulting NUL-terminated string if 57 successful, otherwise NULL and errno set. */ 58 extern char * str_cd_iconv (const char *src, iconv_t cd); 59 60 #endif 61 62 /* Convert an entire string from one encoding to another, using iconv. 63 The original string is the NUL-terminated string starting at SRC. 64 Both the "from" and the "to" encoding must use a single NUL byte at the 65 end of the string (i.e. not UCS-2, UCS-4, UTF-16, UTF-32). 66 Allocate a malloced memory block for the result. 67 Return value: the freshly allocated resulting NUL-terminated string if 68 successful, otherwise NULL and errno set. */ 69 extern char * str_iconv (const char *src, 70 const char *from_codeset, const char *to_codeset); 71 72 73 #ifdef __cplusplus 74 } 75 #endif 76 77 78 #endif /* _STRICONV_H */ 79