CharsetConverter


Object Hierarchy:

GLib.CharsetConverter GLib.CharsetConverter GLib.CharsetConverter GLib.Object GLib.Object GLib.Object->GLib.CharsetConverter GLib.Converter GLib.Converter GLib.Converter->GLib.CharsetConverter GLib.Initable GLib.Initable GLib.Initable->GLib.CharsetConverter

Description:

[ CCode ( type_id = "g_charset_converter_get_type ()" ) ]
public sealed class CharsetConverter : Object, Converter, Initable

`GCharsetConverter` is an implementation of [iface@Gio.

Converter] based on [struct@GLib.IConv].

Example: Charset conversion:

public static int main (string[] args) {
try {
MemoryOutputStream mostream = new MemoryOutputStream (null, GLib.realloc, GLib.free);
CharsetConverter oconverter = new CharsetConverter ("utf-16", "utf-8");
ConverterOutputStream costream = new ConverterOutputStream (mostream, oconverter);
DataOutputStream dostream = new DataOutputStream (costream);
dostream.put_string ("ΑαΒβΓγΔδΕεΖζΗηΘθ\n");
dostream.put_string ("ΙιΚκΛλΜμΝνΞξΟοΠπ\n");
dostream.put_string ("ΡρΣσΤτΥυΦφΧχΨψΩω\n");
mostream.close ();

Bytes bytes = mostream.steal_as_bytes ();

MemoryInputStream mistream = new MemoryInputStream.from_bytes (bytes);
CharsetConverter iconverter = new CharsetConverter ("utf-8", "utf-16");
ConverterInputStream cistream = new ConverterInputStream (mistream, iconverter);
DataInputStream distream = new DataInputStream (cistream);

string line = distream.read_line ();
print (@"$line\n");

line = distream.read_line ();
print (@"$line\n");

line = distream.read_line ();
print (@"$line\n");
} catch (IOError e) {
print ("IOError: %s\n", e.message);
} catch (Error e) {
print ("Error: %s\n", e.message);
}
return 0;
}

valac --pkg gio-2.0 GLib.CharsetConverter.vala


Namespace: GLib
Package: gio-2.0

Content:

Properties:

Creation methods:

Methods:

Inherited Members:

All known members inherited from interface GLib.Converter
All known members inherited from interface GLib.Initable