View Source EQRCode.Encode (EQRCode v0.2.0)
Data encoding in Byte Mode.
Summary
Functions
Returns bits for any binary data.
Encode the binary.
Returns the lowest version for the given binary.
Functions
@spec bits(bitstring()) :: [0 | 1]
Returns bits for any binary data.
Examples
iex> EQRCode.Encode.bits(<<123, 4>>)
[0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0]
@spec encode(binary(), EQRCode.SpecTable.error_correction_level()) :: {EQRCode.SpecTable.version(), EQRCode.SpecTable.error_correction_level(), [0 | 1]}
Encode the binary.
Examples
iex> EQRCode.Encode.encode("hello world!", :l)
{1, :l, [0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1,
0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1,
0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1,
1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0,
0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1,
1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0]}
@spec encode(binary(), EQRCode.SpecTable.error_correction_level(), bitstring()) :: {EQRCode.SpecTable.version(), EQRCode.SpecTable.error_correction_level(), [0 | 1]}
@spec version(binary(), EQRCode.SpecTable.error_correction_level()) :: {:error, :no_version_found} | {:ok, EQRCode.SpecTable.version()}
Returns the lowest version for the given binary.
Examples
iex> EQRCode.Encode.version("hello world!", :l)
{:ok, 1}