Blame lib/striconv.h

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