KaitaiStruct (kaitai_struct v0.1.1)

KataiStruct is the Elixir runtime for Kaitai

Summary

Functions

Takes a binary and returns a new binary with the occurrences of the matching byte stripped from the end

Searches binary for the term and if found, returns a binary terminated at that location. If not found, returns input binary

Takes a binary and specifies its' encoding

Currently accepted encodings

Runs modulo on inputs

Elixir strings will be assumed to be encoded in UTF-8 format unless otherwise specified

Functions

bytes_strip_right(bytes, pad_byte)

@spec bytes_strip_right(bytes :: binary(), pad_byte :: integer()) :: binary()

Takes a binary and returns a new binary with the occurrences of the matching byte stripped from the end

bytes_terminate(bytes, term, include_term)

@spec bytes_terminate(bytes :: binary(), term :: integer(), include_term :: boolean()) ::
  binary()

Searches binary for the term and if found, returns a binary terminated at that location. If not found, returns input binary

bytes_to_str(bytes, encoding)

@spec bytes_to_str(bytes :: binary(), encoding :: String.t()) ::
  {:ok, binary()}
  | {:error, :unsupported_encoding}
  | {:error, {:encoding_error, term()}}

Takes a binary and specifies its' encoding

encodings()

@spec encodings() :: map()

Currently accepted encodings:

  • UTF-8
  • UTF-16
  • UTF-16LE
  • UTF-16BE
  • UTF-32

mod(a, b)

@spec mod(a :: integer(), b :: integer()) :: integer()

Runs modulo on inputs

native_encoding()

@spec native_encoding() :: :utf8

Elixir strings will be assumed to be encoded in UTF-8 format unless otherwise specified