End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Encoding::InvalidByteSequenceError#incomplete_input?
ecerr.incomplete_input? → true or false
transcode.c
View on GitHub ↗
static VALUE
ecerr_incomplete_input(VALUE self)
{
return rb_attr_get(self, id_incomplete_input);
}
Returns true if the invalid byte sequence error is caused by premature end of string.
Example
ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1") begin ec.convert("abc\xA1z") rescue Encoding::InvalidByteSequenceError p $! #=> #<Encoding::InvalidByteSequenceError: "\xA1" followed by "z" on EUC-JP> p $!.incomplete_input? #=> false end begin ec.convert("abc\xA1") ec.finish rescue Encoding::InvalidByteSequenceError p $! #=> #<Encoding::InvalidByteSequenceError: incomplete "\xA1" on EUC-JP> p $!.incomplete_input? #=> true end
See also
#error_bytes
#readagain_bytes
#destination_encoding_name
#source_encoding
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0