VirtualBox

source: kBuild/trunk/src/grep/lib/striconv.h

Last change on this file was 3529, checked in by bird, 3 years ago

Imported grep 3.7 from grep-3.7.tar.gz (sha256: c22b0cf2d4f6bbe599c902387e8058990e1eee99aef333a203829e5fd3dbb342), applying minimal auto-props.

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette