last_error

ec.last_error â exception or nil
Instance Public methods

Returns an exception object for the last conversion. Returns nil if the last conversion did not produce an error.

âerrorâ means that Encoding::InvalidByteSequenceError and Encoding::UndefinedConversionError for #convert and :invalid_byte_sequence, :incomplete_input and :undefined_conversion for #primitive_convert.

ec = Encoding::Converter.new("utf-8", "iso-8859-1")
p ec.primitive_convert(src="\xf1abcd", dst="")       #=> :invalid_byte_sequence
p ec.last_error      #=> #<Encoding::InvalidByteSequenceError: "\xF1" followed by "a" on UTF-8>
p ec.primitive_convert(src, dst, nil, 1)             #=> :destination_buffer_full
p ec.last_error      #=> nil
doc_ruby_on_rails
2015-04-04 18:52:33
Comments
Leave a Comment

Please login to continue.