1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD 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 gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module glib.IConv;
26 
27 private import glib.Str;
28 private import gtkc.glib;
29 public  import gtkc.glibtypes;
30 
31 
32 /**
33  * The GIConv struct wraps an iconv() conversion descriptor. It contains
34  * private data and should only be accessed using the following functions.
35  */
36 
37 /**
38  * Same as the standard UNIX routine iconv(), but
39  * may be implemented via libiconv on UNIX flavors that lack
40  * a native implementation.
41  *
42  * GLib provides g_convert() and g_locale_to_utf8() which are likely
43  * more convenient than the raw iconv wrappers.
44  *
45  * Params:
46  *     inbuf = bytes to convert
47  *     inbytesLeft = inout parameter, bytes remaining to convert in @inbuf
48  *     outbuf = converted output bytes
49  *     outbytesLeft = inout parameter, bytes available to fill in @outbuf
50  *
51  * Return: count of non-reversible conversions, or -1 on error
52  */
53 public size_t iconv(GIConv converter, ref string inbuf, ref string outbuf)
54 {
55 	char* outinbuf = Str.toStringz(inbuf);
56 	size_t inbytesLeft;
57 	char* outoutbuf = Str.toStringz(outbuf);
58 	size_t outbytesLeft;
59 	
60 	auto p = g_iconv(converter, &outinbuf, &inbytesLeft, &outoutbuf, &outbytesLeft);
61 	
62 	inbuf = Str.toString(outinbuf, inbytesLeft);
63 	outbuf = Str.toString(outoutbuf, outbytesLeft);
64 	
65 	return p;
66 }
67 
68 /**
69  * Same as the standard UNIX routine iconv_close(), but
70  * may be implemented via libiconv on UNIX flavors that lack
71  * a native implementation. Should be called to clean up
72  * the conversion descriptor from g_iconv_open() when
73  * you are done converting things.
74  *
75  * GLib provides g_convert() and g_locale_to_utf8() which are likely
76  * more convenient than the raw iconv wrappers.
77  *
78  * Return: -1 on error, 0 on success
79  */
80 public int close(GIConv converter)
81 {
82 	return g_iconv_close(converter);
83 }
84 
85 /**
86  * Same as the standard UNIX routine iconv_open(), but
87  * may be implemented via libiconv on UNIX flavors that lack
88  * a native implementation.
89  *
90  * GLib provides g_convert() and g_locale_to_utf8() which are likely
91  * more convenient than the raw iconv wrappers.
92  *
93  * Params:
94  *     toCodeset = destination codeset
95  *     fromCodeset = source codeset
96  *
97  * Return: a "conversion descriptor", or (GIConv)-1 if
98  *     opening the converter failed.
99  */
100 public GIConv open(string toCodeset, string fromCodeset)
101 {
102 	return g_iconv_open(Str.toStringz(toCodeset), Str.toStringz(fromCodeset));
103 }