error_bytes

ecerr.error_bytes â string
Instance Public methods

Returns the discarded bytes when Encoding::InvalidByteSequenceError occurs.

ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1")
begin
  ec.convert("abc\xA1\xFFdef")
rescue Encoding::InvalidByteSequenceError
  p $!      #=> #<Encoding::InvalidByteSequenceError: "\xA1" followed by "\xFF" on EUC-JP>
  puts $!.error_bytes.dump          #=> "\xA1"
  puts $!.readagain_bytes.dump      #=> "\xFF"
end
doc_ruby_on_rails
2015-04-04 19:52:28
Comments
Leave a Comment

Please login to continue.