binmode#

Synopsis#

binmode(STDOUT);              # set binary mode (no CRLF translation)
binmode(STDOUT, ":utf8");     # set UTF-8 encoding layer
binmode(STDOUT, ":raw");      # remove all layers
binmode($fh, ":encoding(UTF-8)");

Description#

Sets the I/O discipline (encoding layer) for a filehandle.

Configures the encoding layer on a filehandle. When called with just a filehandle, sets binary mode (disabling any CRLF translation, though Linux does not perform CRLF translation by default). When called with a layer string, applies the specified encoding.

Currently recognized layers:

  • :utf8, :encoding(UTF-8) – mark the handle as UTF-8

  • :raw, :bytes – mark the handle as raw bytes

Returns true on success, false on failure.

See also#

open, PerlIO, Encode