End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
String#encode!
encode!(dst_encoding = Encoding.default_internal, **enc_opts) → self
encode!(dst_encoding, src_encoding, **enc_opts) → self
transcode.c
View on GitHub ↗
static VALUE
str_encode_bang(int argc, VALUE *argv, VALUE str)
{
VALUE newstr;
int encidx;
rb_check_frozen(str);
newstr = str;
encidx = str_transcode(argc, argv, &newstr);
if (encidx < 0) return str;
if (newstr == str) {
rb_enc_associate_index(str, encidx);
return str;
}
rb_str_shared_replace(str, newstr);
return str_encode_associate(str, encidx);
}
Like encode, but applies encoding changes to self; returns self.