BasedDumps.jl

Binary memory or file dumpers in base 2 through 16 formats
Author wherrera10
Popularity
0 Stars
Updated Last
1 Year Ago
Started In
October 2023

BasedDumps.jl

Binary memory and file dumpers in base 2 through 16 formats

dumper

Functions:

function baseddump

5 methods.

function baseddump(io::IO, data::Vector{UInt8}; base = 16, offset = 0, len = -1)

function baseddump(io::IO, data::AbstractArray; base = 16, offset = 0, len = -1)

function baseddump(data; base = 16, offset = 0, len = -1)

Print (to stdout, or if specified io) a dump of `data`. The function will attempt
to convert non-UInt8 data to a vector of UInt8 bytes. If a string is passed for 
data, the function will interpret this as a file name for the data, so for string
data textdump() should be used, as shown below. The portion of data that is 
dumped defaults to all of data, or else, if specified, from `offset` to `len`.
The `offset` is printed as the first hex numeric entry on the left, and the final
count of bytes dumped is printed as the last hex number on the left.
The `base` used to print the data is between 16 (default) and 2 (binary).
The data is formatted similar to the format of the unix utilities `hexdump` or
`xxd` for bases 16 and 2, the decimal format for `base` 10 is similar to unix
`hexdump` but with decimal format and similarly for base 8 and octal format.
Any base between 2 and 16 is supported, but there are shorter function names
for base 2 (binary), base 8 (octal), base 10 (decimal), and the default 16
(hexadecimal).

function baseddump(to::IO, from::IO; base = 16, offset = 0, len = -1)

function baseddump(to::IO, filename::AbstractString; base = 16, offset = 0, len = -1)

Print (to stdout, or if specified to the IO `to`) a dump of the stream `from` or file
`filename` as bytes. The portion dumped defaults to all of the data until eof(), 
or else, if specified, from `offset` to `len`.

Note that these functions have shorter versions:

hexdump which defaults to base 16,

xxd which defaults to base 2,

octdump which defaults to base 8, and

decdump which defaults to base 10.

Examples:

hexdump("test.so") will dump the contents of file "test.so" as a hex display to stdout.

xxd(stderr, s, offset = 16, length = 1008) will dump the bytes in s[16:16+1008-1], where s 
is a vector of bytes, to stderr in a binary format.

textdump(io::IO, txt::AbstractString; base = 16, off = 0, len = -1)

Dump (with `baseddump`) the string `txt`. Julia strings will be interpreted
as utf-8 text, with mulitbyte chars displayed in little endian order.

textdump(txt; base = 16, offset = 0, len = -1)

This method is the same as the previous method of that name, but dumps only to stdout.