Skip to content
instance method

StringIO#external_encoding

() -> ::Encoding
external_encoding → encoding or nil

Returns an Encoding object that represents the encoding of the string; see Encodings:

Example
strio = StringIO.new('foo')
strio.external_encoding # => #<Encoding:UTF-8>

Returns nil if self has no string and is in write mode:

Example
strio = StringIO.new(nil, 'w+')
strio.external_encoding # => nil
See also #eof? #fcntl #eof #fileno also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0