ConverterOutputStream


Object Hierarchy:

GLib.ConverterOutputStream GLib.ConverterOutputStream GLib.ConverterOutputStream GLib.FilterOutputStream GLib.FilterOutputStream GLib.FilterOutputStream->GLib.ConverterOutputStream GLib.OutputStream GLib.OutputStream GLib.OutputStream->GLib.FilterOutputStream GLib.Object GLib.Object GLib.Object->GLib.OutputStream GLib.PollableOutputStream GLib.PollableOutputStream GLib.PollableOutputStream->GLib.ConverterOutputStream

Description:

[ CCode ( type_id = "g_converter_output_stream_get_type ()" ) ]
public class ConverterOutputStream : FilterOutputStream, PollableOutputStream

Converter output stream implements [class@Gio.

OutputStream] and allows conversion of data of various types during reading.

As of GLib 2.34, `GConverterOutputStream` implements [iface@Gio.PollableOutputStream].

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 class GLib.FilterOutputStream
All known members inherited from interface GLib.PollableOutputStream