putback(p1 = v1)
Instance Public methods
call-seq
1 2 | ec.putback -> string ec.putback(max_numbytes) -> string |
Put back the bytes which will be converted.
The bytes are caused by invalid_byte_sequence error. When invalid_byte_sequence error, some bytes are discarded and some bytes are buffered to be converted later. The latter bytes can be put back. It can be observed by Encoding::InvalidByteSequenceError#readagain_bytes and #primitive_errinfo.
1 2 3 4 5 6 7 | ec = Encoding::Converter. new ( "utf-16le" , "iso-8859-1" ) src = "\x00\xd8\x61\x00" dst = "" p ec.primitive_convert(src, dst) #=> :invalid_byte_sequence p ec.primitive_errinfo #=> [:invalid_byte_sequence, "UTF-16LE", "UTF-8", "\x00\xD8", "a\x00"] p ec.putback #=> "a\x00" p ec.putback #=> "" # no more bytes to put back |
Please login to continue.