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 
39 /**
40  * Same as the standard UNIX routine iconv(), but
41  * may be implemented via libiconv on UNIX flavors that lack
42  * a native implementation.
43  *
44  * GLib provides g_convert() and g_locale_to_utf8() which are likely
45  * more convenient than the raw iconv wrappers.
46  *
47  * Params:
48  *     inbuf = bytes to convert
49  *     inbytesLeft = inout parameter, bytes remaining to convert in @inbuf
50  *     outbuf = converted output bytes
51  *     outbytesLeft = inout parameter, bytes available to fill in @outbuf
52  *
53  * Return: count of non-reversible conversions, or -1 on error
54  */
55 public size_t iconv(GIConv converter, ref string inbuf, ref string outbuf)
56 {
57 	char* outinbuf = Str.toStringz(inbuf);
58 	size_t inbytesLeft;
59 	char* outoutbuf = Str.toStringz(outbuf);
60 	size_t outbytesLeft;
61 	
62 	auto p = g_iconv(converter, &outinbuf, &inbytesLeft, &outoutbuf, &outbytesLeft);
63 	
64 	inbuf = Str.toString(outinbuf, inbytesLeft);
65 	outbuf = Str.toString(outoutbuf, outbytesLeft);
66 	
67 	return p;
68 }
69 
70 /**
71  * Same as the standard UNIX routine iconv_close(), but
72  * may be implemented via libiconv on UNIX flavors that lack
73  * a native implementation. Should be called to clean up
74  * the conversion descriptor from g_iconv_open() when
75  * you are done converting things.
76  *
77  * GLib provides g_convert() and g_locale_to_utf8() which are likely
78  * more convenient than the raw iconv wrappers.
79  *
80  * Return: -1 on error, 0 on success
81  */
82 public int close(GIConv converter)
83 {
84 	return g_iconv_close(converter);
85 }
86 
87 /**
88  * Same as the standard UNIX routine iconv_open(), but
89  * may be implemented via libiconv on UNIX flavors that lack
90  * a native implementation.
91  *
92  * GLib provides g_convert() and g_locale_to_utf8() which are likely
93  * more convenient than the raw iconv wrappers.
94  *
95  * Params:
96  *     toCodeset = destination codeset
97  *     fromCodeset = source codeset
98  *
99  * Return: a "conversion descriptor", or (GIConv)-1 if
100  *     opening the converter failed.
101  */
102 public GIConv open(string toCodeset, string fromCodeset)
103 {
104 	return g_iconv_open(Str.toStringz(toCodeset), Str.toStringz(fromCodeset));
105 }