Utf8Codec
¶

-
class
Utf8Codec
[source]¶ Bases:
taurus.core.util.codecs.Codec
A codec able to encode/decode utf8 strings to/from bytes. Useful to adapt i/o encodings in a codec pipe.
Example:
>>> from taurus.core.util.codecs import CodecFactory >>> cf = CodecFactory() >>> codec = cf.getCodec('zip_utf8_json') >>> >>> # first encode something >>> data = { 'hello' : 'world', 'goodbye' : 1000 } >>> format, encoded_data = codec.encode(("", data)) >>> >>> # now decode it >>> _, decoded_data = codec.decode((format, encoded_data)) >>> print decoded_data
-
decode
(data, *args, **kwargs)[source]¶ decodes the given data from a bytes.
Parameters: data ( sequence[str, obj]
) – a sequence of two elements where the first item is the encoding format of the second item objectReturn type: sequence[str, obj]
Returns: a sequence of two elements where the first item is the encoding format of the second item object
-
encode
(data, *args, **kwargs)[source]¶ Encodes the given utf8 string to bytes.
Parameters: data ( sequence[str, obj]
) – a sequence of two elements where the first item is the encoding format of the second item objectReturn type: sequence[str, obj]
Returns: a sequence of two elements where the first item is the encoding format of the second item object
-