Skip to content

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

instance method

Encoding::Converter#replacement=

ec.replacement = string

Sets the replacement string.

Example
ec = Encoding::Converter.new("utf-8", "us-ascii", :undef => :replace)
ec.replacement = "<undef>"
p ec.convert("a \u3042 b")      #=> "a <undef> b"
See also #replacement #source_encoding #putback also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0