Blame gettext-runtime/gnulib-lib/striconv.h

Packit 5b56b6
/* Charset conversion.
Packit 5b56b6
   Copyright (C) 2001-2004, 2006-2007, 2009-2015 Free Software Foundation, Inc.
Packit 5b56b6
   Written by Bruno Haible and Simon Josefsson.
Packit 5b56b6
Packit 5b56b6
   This program is free software; you can redistribute it and/or modify
Packit 5b56b6
   it under the terms of the GNU General Public License as published by
Packit 5b56b6
   the Free Software Foundation; either version 3, or (at your option)
Packit 5b56b6
   any later version.
Packit 5b56b6
Packit 5b56b6
   This program is distributed in the hope that it will be useful,
Packit 5b56b6
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 5b56b6
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 5b56b6
   GNU General Public License for more details.
Packit 5b56b6
Packit 5b56b6
   You should have received a copy of the GNU General Public License
Packit 5b56b6
   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
Packit 5b56b6
Packit 5b56b6
#ifndef _STRICONV_H
Packit 5b56b6
#define _STRICONV_H
Packit 5b56b6
Packit 5b56b6
#include <stddef.h>
Packit 5b56b6
#if HAVE_ICONV
Packit 5b56b6
#include <iconv.h>
Packit 5b56b6
#endif
Packit 5b56b6
Packit 5b56b6
Packit 5b56b6
#ifdef __cplusplus
Packit 5b56b6
extern "C" {
Packit 5b56b6
#endif
Packit 5b56b6
Packit 5b56b6
Packit 5b56b6
#if HAVE_ICONV
Packit 5b56b6
Packit 5b56b6
/* Convert an entire string from one encoding to another, using iconv.
Packit 5b56b6
   The original string is at [SRC,...,SRC+SRCLEN-1].
Packit 5b56b6
   The conversion descriptor is passed as CD.
Packit 5b56b6
   *RESULTP and *LENGTH should initially be a scratch buffer and its size,
Packit 5b56b6
   or *RESULTP can initially be NULL.
Packit 5b56b6
   May erase the contents of the memory at *RESULTP.
Packit 5b56b6
   Return value: 0 if successful, otherwise -1 and errno set.
Packit 5b56b6
   If successful: The resulting string is stored in *RESULTP and its length
Packit 5b56b6
   in *LENGTHP.  *RESULTP is set to a freshly allocated memory block, or is
Packit 5b56b6
   unchanged if no dynamic memory allocation was necessary.  */
Packit 5b56b6
extern int mem_cd_iconv (const char *src, size_t srclen, iconv_t cd,
Packit 5b56b6
                         char **resultp, size_t *lengthp);
Packit 5b56b6
Packit 5b56b6
/* Convert an entire string from one encoding to another, using iconv.
Packit 5b56b6
   The original string is the NUL-terminated string starting at SRC.
Packit 5b56b6
   The conversion descriptor is passed as CD.  Both the "from" and the "to"
Packit 5b56b6
   encoding must use a single NUL byte at the end of the string (i.e. not
Packit 5b56b6
   UCS-2, UCS-4, UTF-16, UTF-32).
Packit 5b56b6
   Allocate a malloced memory block for the result.
Packit 5b56b6
   Return value: the freshly allocated resulting NUL-terminated string if
Packit 5b56b6
   successful, otherwise NULL and errno set.  */
Packit 5b56b6
extern char * str_cd_iconv (const char *src, iconv_t cd);
Packit 5b56b6
Packit 5b56b6
#endif
Packit 5b56b6
Packit 5b56b6
/* Convert an entire string from one encoding to another, using iconv.
Packit 5b56b6
   The original string is the NUL-terminated string starting at SRC.
Packit 5b56b6
   Both the "from" and the "to" encoding must use a single NUL byte at the
Packit 5b56b6
   end of the string (i.e. not UCS-2, UCS-4, UTF-16, UTF-32).
Packit 5b56b6
   Allocate a malloced memory block for the result.
Packit 5b56b6
   Return value: the freshly allocated resulting NUL-terminated string if
Packit 5b56b6
   successful, otherwise NULL and errno set.  */
Packit 5b56b6
extern char * str_iconv (const char *src,
Packit 5b56b6
                         const char *from_codeset, const char *to_codeset);
Packit 5b56b6
Packit 5b56b6
Packit 5b56b6
#ifdef __cplusplus
Packit 5b56b6
}
Packit 5b56b6
#endif
Packit 5b56b6
Packit 5b56b6
Packit 5b56b6
#endif /* _STRICONV_H */