module

Crowbar::Encoding

Binary Input and Output Representation Codecs. Provides transparent conversion between human-friendly CLI string encodings (hexadecimal, C-escapes, bitstrings, base64) and raw binary buffers.

Class methods

decode(input : String | Bytes | Buffer, format : Format | String | Symbol = Format::Raw) : Buffer

Decodes an input string, bytes, or buffer into a raw binary Buffer

Source
decode_base64(str : String) : Buffer

Decodes Base64 strings to raw binary Buffer

Source
decode_bit(str : String) : Buffer

Decodes bitstring representations (e.g. "0b01010100 01110010" or "0101010001110010")

Source
decode_escape(str : String) : Buffer

Decodes C-style escape representations (e.g. "\x64\xaf\x00\r\n\t")

Source
decode_hex(str : String) : Buffer

Decodes hexadecimal string representations (e.g. "414243", "0x41 0x42", "41:42:43")

Source
detect(input : String) : Format

Auto-detects the most probable encoding of an input string representation

Source
encode(buffer : Buffer | Bytes, format : Format | String | Symbol = Format::Raw) : String

Encodes a binary buffer into the requested string representation

Source

Nested types