Module binary

An implementation of a subset of the Erlang/OTP binary interface.

Function Index

at/2 Get a byte from a binary by index.
decode_hex/1 Decodes a hex encoded binary into a binary.
encode_hex/1 Encodes a binary into a hex encoded binary using the specified case for the hexadecimal digits "a" to "f".
encode_hex/2 Encodes a binary into a hex encoded binary using the specified case for the hexadecimal digits "a" to "f".
part/3Get the part of a given binary.
split/2Split a binary according to pattern.
split/3Split a binary according to pattern.

Function Details

at/2


at(Binary::binary(), Index::non_neg_integer()) -> byte()

Binary: binary to get a byte from
Index: 0-based index of the byte to return

returns: value of the byte from the binary

Get a byte from a binary by index.

decode_hex/1


decode_hex(Data::<<_:_*16>>) -> binary()

Data: hex encoded binary to decode

returns: decoded binary

Decodes a hex encoded binary into a binary.

encode_hex/1


encode_hex(Data::binary()) -> binary()

Data: binary data to convert into hex encoded binary

returns: hex encoded binary

Encodes a binary into a hex encoded binary using the specified case for the hexadecimal digits “a” to “f”.

encode_hex/2


encode_hex(Data::binary(), Case::lowercase | uppercase) -> binary()

Data: binary data to convert into hex encoded binary
Case: which case to encode into

returns: hex encoded binary

Encodes a binary into a hex encoded binary using the specified case for the hexadecimal digits “a” to “f”.

part/3


part(Binary::binary(), Pos::non_neg_integer(), Len::integer()) -> binary()

Binary: binary to extract a subbinary from
Pos: 0-based index of the subbinary to extract
Len: length, in bytes, of the subbinary to extract.

returns: a subbinary from Binary

Get the part of a given binary. A negative length can be passed to count bytes backwards.

split/2


split(Binary::binary(), Pattern::binary()) -> [binary()]

Binary: binary to split
Pattern: pattern to perform the split

returns: a list composed of one or two binaries

Equivalent to split(Binary, Pattern, []).

Split a binary according to pattern. If pattern is not found, returns a singleton list with the passed binary. Unlike Erlang/OTP, pattern must be a binary.

split/3


split(Binary::binary(), Pattern::binary(), Option::[global]) -> [binary()]

Binary: binary to split
Pattern: pattern to perform the split

returns: a list composed of one or two binaries

Split a binary according to pattern. If pattern is not found, returns a singleton list with the passed binary. Unlike Erlang/OTP, pattern must be a binary. Only implemented option is global