replacement=

ec.replacement = string Instance Public methods Sets the replacement string. ec = Encoding::Converter.new("utf-8", "us-ascii", :undef => :replace) ec.replacement = "<undef>" p ec.convert("a \u3042 b") #=> "a <undef> b"

replacement

ec.replacement â string Instance Public methods Returns the replacement string. ec = Encoding::Converter.new("euc-jp", "us-ascii") p ec.replacement #=> "?" ec = Encoding::Converter.new("euc-jp", "utf-8") p ec.replacement #=> "\uFFFD"

putback

putback(p1 = v1) Instance Public methods call-seq 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. ec = Encodin

primitive_errinfo

ec.primitive_errinfo â array Instance Public methods #primitive_errinfo returns important information regarding the last error as a 5-element array: [result, enc1, enc2, error_bytes, readagain_bytes] result is the last result of primitive_convert. Other elements are only meaningful when result is :invalid_byte_sequence, :incomplete_input or :undefined_conversion. enc1 and enc2 indicate a conversion step as a pair of strings. For example, a converter from EUC-JP to ISO-8859-1 conv

primitive_convert

ec.primitive_convert(source_buffer, destination_buffer) â symbolec.primitive_convert(source_buffer, destination_buffer, destination_byteoffset) â symbolec.primitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize) â symbolec.primitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize, opt) â symbol Instance Public methods possible opt elements: hash form: :partial_input => true # source bu

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="") #=>

inspect

ec.inspect â string Instance Public methods Returns a printable version of ec ec = Encoding::Converter.new("iso-8859-1", "utf-8") puts ec.inspect #=> #<Encoding::Converter: ISO-8859-1 to UTF-8>

insert_output

ec.insert_output(string) â nil Instance Public methods Inserts string into the encoding converter. The string will be converted to the destination encoding and output on later conversions. If the destination encoding is stateful, string is converted according to the state and the state is updated. This method should be used only when a conversion error occurs. ec = Encoding::Converter.new("utf-8", "iso-8859-1") src = "HIRAGANA LETTER A is \u{3042}." dst = "" p ec.primitive_convert

finish

ec.finish â string Instance Public methods Finishes the converter. It returns the last part of the converted string. ec = Encoding::Converter.new("utf-8", "iso-2022-jp") p ec.convert("\u3042") #=> "\e$B$\"" p ec.finish #=> "\e(B"

destination_encoding

ec.destination_encoding â encoding Instance Public methods Returns the destination encoding as an Encoding object.