Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

String#encode!

str.encode!(encoding, **options) → str
str.encode!(dst_encoding, src_encoding, **options) → str

The first form transcodes the contents of str from str.encoding to encoding. The second form transcodes the contents of str from src_encoding to dst_encoding. The options keyword arguments give details for conversion. See String#encode for details. Returns the string even if no changes were made.

See also #encode #encoding #empty? #end_with? also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0