hexdump_core#

hexrec.hexdump.hexdump_core(infile=None, outfile=None, one_byte_octal=False, one_byte_hex=False, one_byte_char=False, canonical=False, two_bytes_decimal=False, two_bytes_octal=False, two_bytes_hex=False, color=None, format=None, format_file=None, length=None, skip=None, no_squeezing=False, upper=False, width=16, linesep=None, format_order=None)[source]#

Emulation of the hexdump utility core.

Parameters:
  • infile (str or bytes) – Input data. If str, it is considered as the input file path. If bytes, it is the input byte chunk. If None, it reads from the standard input.

  • outfile (str or bytes) – Output data. If str, it is considered as the output file path. If bytes, it is the output byte chunk. If None, it writes to the standard output.

  • one_byte_octal (bool) – One-byte octal display. Display the input offset in hexadecimal, followed by sixteen space-separated, three-column, zero-filled bytes of input data, in octal, per line.

  • one_byte_hex (bool) – One-byte hexadecimal display. Display the input offset in hexadecimal, followed by sixteen space-separated, two-column, zero-filled bytes of input data, in hexadecimal, per line.

  • one_byte_char (bool) – One-byte character display. Display the input offset in hexadecimal, followed by sixteen space-separated, three-column, space-filled characters of input data per line.

  • canonical (bool) – Canonical hex+ASCII display. Display the input offset in hexadecimal, followed by sixteen space-separated, two-column, hexadecimal bytes, followed by the same sixteen bytes in %_p format enclosed in | characters. Invoking the program as hd implies this option.

  • two_bytes_decimal (bool) – Two-byte decimal display. Display the input offset in hexadecimal, followed by eight space-separated, five-column, zero-filled, two-byte units of input data, in unsigned decimal, per line.

  • two_bytes_octal (bool) – Two-byte octal display. Display the input offset in hexadecimal, followed by eight space-separated, six-column, zero-filled, two-byte quantities of input data, in octal, per line.

  • two_bytes_hex (bool) – Two-byte hexadecimal display. Display the input offset in hexadecimal, followed by eight space-separated, four-column, zero-filled, two-byte quantities of input data, in hexadecimal, per line.

  • color (str) – CURRENTLY NOT SUPPORTED. Please provide None.

  • format (str) – CURRENTLY NOT SUPPORTED. Please provide None.

  • format_file (str) – CURRENTLY NOT SUPPORTED. Please provide None.

  • length (int) – Interpret only length bytes of input.

  • skip (int) – Skip offset bytes from the beginning of the input.

  • no_squeezing (bool) – The -v option causes hexdump to display all input data. Without the -v option, any number of groups of output lines which would be identical to the immediately preceding group of output lines (except for the input offsets), are replaced with a line comprised of a single asterisk.

  • upper (bool) – Uses upper case hex letters on address and data.

  • width (int) – Number of bytes per line.

  • linesep (bytes) – Line separator bytes.

  • format_order (list of str) – If not None, it indicates the order of display options (one_byte_octal, one_byte_hex, one_byte_char, canonical, two_bytes_decimal, two_bytes_octal, two_bytes_hex). Duplicates are allowed. Only those with the corresponding boolean argument true are used.

Returns:

stream – The handle to the output stream.