GLib.IOChannel.prototype.set_encoding

function set_encoding(encoding: String): GLib.IOStatus {
    // Gjs wrapper for g_io_channel_set_encoding()
}
  

Sets the encoding for the input/output of the channel. The internal encoding is always UTF-8. The default encoding for the external file is UTF-8.

The encoding null is safe to use with binary data.

The encoding can only be set if one of the following conditions is true:

- The channel was just created, and has not been written to or read from yet.

- The channel is write-only.

- The channel is a file, and the file pointer was just repositioned by a call to GLib.IOChannel.prototype.seek_position. (This flushes all the internal buffers.)

- The current encoding is null or UTF-8.

- One of the (new API) read functions has just returned GLib.IOStatus.eof (or, in the case of GLib.IOChannel.prototype.read_to_end, GLib.IOStatus.normal).

- One of the functions GLib.IOChannel.prototype.read_chars or GLib.IOChannel.prototype.read_unichar has returned GLib.IOStatus.again or GLib.IOStatus.error. This may be useful in the case of GLib.ConvertError.illegal_sequence. Returning one of these statuses from GLib.IOChannel.prototype.read_line, GLib.IOChannel.prototype.read_line_string, or GLib.IOChannel.prototype.read_to_end does not guarantee that the encoding can be changed.

Channels which do not meet one of the above conditions cannot call GLib.IOChannel.prototype.seek_position with an offset of GLib.SeekType.cur, and, if they are "seekable", cannot call GLib.IOChannel.prototype.write_chars after calling one of the API "read" functions.

encoding

the encoding type

Returns

GLib.IOStatus.normal if the encoding was successfully set