class encodings.Transcoder
Description
Class to convert data from one character set to another.
An important thing to remember when using a Transcoder is to call encodings.Transcoder#close once all data has been fed to the transcoder, as some character sets have reset byte sequences that must be occur at the end of the data - ISO-2022-JP for example.
Methods
Constructor
new encodings.Transcoder(source, dest)
-
source(String) – character set -
dest(String) – character set
Create a transcoder which transcoder data from source and converts it into dest.
Instance properties
Instance methods
-
close #
encodings.Transcoder#close([output]) ⇒ binary.Binary-
output(binary.ByteArray) – something
Signal to the transcoder that no further input will be given, and give the underlying conversion mechanism the chance to append any necessary final data.
Once closed, a transcoder cannot be reused.
If
outputis provided, any output will be appended to the byte array, and the same byte array will be returned. Otherwise a newbinary.ByteStringwill be returned. -
-
push #
encodings.Transcoder#push(input[, output]) ⇒ binary.Binary-
input(binary.Binary) – chunk of data to convert -
output(binary.ByteArray) – output byte array
Convert a chunk of data, and return the converted data, plus any buffered output.
If
outputis provided, any output will be appended to the byte array, and the same byte array will be returned. Otherwise a newbinary.ByteStringwill be returned.It is possible that no bytes will be output (for example if only the start of a multi-byte character is passed as input) in which case no data will be appended to
outputor an empty ByteString will be returned.Will throw an Error when invalid data is found.
-
-
pushAccumulate #
encodings.Transcoder#pushAccumulate(input) ⇒ undefined-
input(binary.Binary) – chunk of data to convert
Convert a chunk of data and store it in the internal buffers. Buffered data will be returned by next call to
encodings.Transcoder#pushorencodings.Transcoder#close. -