End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
ARGF#external_encoding
ARGF.external_encoding → encoding
io.c
View on GitHub ↗
static VALUE
argf_external_encoding(VALUE argf)
{
if (!RTEST(ARGF.current_file)) {
return rb_enc_from_encoding(rb_default_external_encoding());
}
return rb_io_external_encoding(rb_io_check_io(ARGF.current_file));
}
Returns the external encoding for files read from ARGF as an Encoding object. The external encoding is the encoding of the text as stored in a file. Contrast with ARGF.internal_encoding, which is the encoding used to represent this text within Ruby.
To set the external encoding use ARGF.set_encoding.
For example:
Example
ARGF.external_encoding #=> #<Encoding:UTF-8>