Skip to content
instance method

IO#set_encoding

(?::String | ::Encoding ext_or_ext_int_enc) -> self
(?::String | ::Encoding ext_or_ext_int_enc, ?::String | ::Encoding int_enc) -> self
set_encoding(ext_enc) → self
set_encoding(ext_enc, int_enc, **enc_opts) → self
set_encoding('ext_enc:int_enc', **enc_opts) → self

See Encodings.

Argument ext_enc, if given, must be an Encoding object or a String with the encoding name; it is assigned as the encoding for the stream.

Argument int_enc, if given, must be an Encoding object or a String with the encoding name; it is assigned as the encoding for the internal string.

Argument 'ext_enc:int_enc', if given, is a string containing two colon-separated encoding names; corresponding Encoding objects are assigned as the external and internal encodings for the stream.

If the external encoding of a string is binary/ASCII-8BIT, the internal encoding of the string is set to nil, since no transcoding is needed.

Optional keyword arguments enc_opts specify Encoding options.

See also #seek #set_encoding_by_bom #scroll_forward #stat also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0