source: appstream-generator/build/girepo/glib/IConv.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 3 years ago

Initial release

File size: 3.0 KB
RevLine 
[4841]1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module glib.IConv;
22
23private import gi.glib;
24public  import gi.glibtypes;
25private import glib.Str;
26
27
28/**
29 * The GIConv struct wraps an iconv() conversion descriptor. It contains
30 * private data and should only be accessed using the following functions.
31 */
32
33/**
34 * Same as the standard UNIX routine iconv(), but
35 * may be implemented via libiconv on UNIX flavors that lack
36 * a native implementation.
37 *
38 * GLib provides g_convert() and g_locale_to_utf8() which are likely
39 * more convenient than the raw iconv wrappers.
40 *
41 * Params:
42 *     inbuf = bytes to convert
43 *     inbytesLeft = inout parameter, bytes remaining to convert in @inbuf
44 *     outbuf = converted output bytes
45 *     outbytesLeft = inout parameter, bytes available to fill in @outbuf
46 *
47 * Returns: count of non-reversible conversions, or -1 on error
48 */
49public size_t iconv(GIConv converter, ref string inbuf, ref string outbuf)
50{
51        char* outinbuf = Str.toStringz(inbuf);
52        size_t inbytesLeft;
53        char* outoutbuf = Str.toStringz(outbuf);
54        size_t outbytesLeft;
55       
56        auto p = g_iconv(converter, &outinbuf, &inbytesLeft, &outoutbuf, &outbytesLeft);
57       
58        inbuf = Str.toString(outinbuf, inbytesLeft);
59        outbuf = Str.toString(outoutbuf, outbytesLeft);
60       
61        return p;
62}
63
64/**
65 * Same as the standard UNIX routine iconv_close(), but
66 * may be implemented via libiconv on UNIX flavors that lack
67 * a native implementation. Should be called to clean up
68 * the conversion descriptor from g_iconv_open() when
69 * you are done converting things.
70 *
71 * GLib provides g_convert() and g_locale_to_utf8() which are likely
72 * more convenient than the raw iconv wrappers.
73 *
74 * Returns: -1 on error, 0 on success
75 */
76public int close(GIConv converter)
77{
78        return g_iconv_close(converter);
79}
80
81/**
82 * Same as the standard UNIX routine iconv_open(), but
83 * may be implemented via libiconv on UNIX flavors that lack
84 * a native implementation.
85 *
86 * GLib provides g_convert() and g_locale_to_utf8() which are likely
87 * more convenient than the raw iconv wrappers.
88 *
89 * Params:
90 *     toCodeset = destination codeset
91 *     fromCodeset = source codeset
92 *
93 * Returns: a "conversion descriptor", or (GIConv)-1 if
94 *     opening the converter failed.
95 */
96public GIConv open(string toCodeset, string fromCodeset)
97{
98        return g_iconv_open(Str.toStringz(toCodeset), Str.toStringz(fromCodeset));
99}
Note: See TracBrowser for help on using the repository browser.