Otera.Bytes (otera v0.1.0)

Copy Markdown View Source

A Python bytes value, which str.encode() gives. It prints like Python, such as b'caf\xc3\xa9', has a length in bytes, iterates as integers, and decode() gives the string back.

Summary

Functions

Decodes bytes like bytes.decode(encoding).

Encodes string like str.encode(encoding, errors), for the codecs UTF-8, ASCII and Latin-1 with strict errors.

Returns the Python repr() of bytes.

Types

t()

@type t() :: %Otera.Bytes{data: binary()}

Functions

decode(bytes, encoding)

@spec decode(t(), String.t()) :: String.t()

Decodes bytes like bytes.decode(encoding).

encode(string, encoding)

@spec encode(String.t(), String.t()) :: t()

Encodes string like str.encode(encoding, errors), for the codecs UTF-8, ASCII and Latin-1 with strict errors.

repr(bytes)

@spec repr(t()) :: String.t()

Returns the Python repr() of bytes.