package hex
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=2e67eeca1b03049307a30831b5cd694bcb2d3e7f2a6b4fb597fbdb647351b4dc
sha512=baa09b47a90f0a54ad2becfb272f0674219e4fc0c03559deff26aaf13ccd59258b31bf98e56c44a5a8fa03437e3eba2bf5f0cd76e52d184d26cfb1170c490462
doc/hex/Hex/index.html
Module Hex
Source
Hexadecimal encoding.
Hex
defines hexadecimal encodings for characters, strings and Cstruct.t buffers.
The type var hexadecimal values.
Characters
of_char c
is the the hexadecimal encoding of the character c
.
to_char x y
is the character correspondong to the xy
hexadecimal encoding.
Strings
of_string s
is the hexadecimal representation of the binary string s
. If ignore
is set, skip the characters in the list when converting. E.g. of_string ~ignore:[' '] "Mirage OS"
is `Hex "4d69726167654f53"
, of_string "Mirage OS"
is `Hex "4d6972616765204f53"
(with a "20" before the "OS" ("4f53")). The default value of ignore
is []
).
If you have a hex string as input (i.e. "4f53"), you can use to_string (`Hex "4f53")
to decode it to a binary string ("OS").
Bytes
of_bytes s
is the hexadecimal representation of the binary string s
. If ignore
is set, skip the characters in the list when converting. Eg of_bytes ~ignore:[' '] "a f"
. The default value of ignore
is []
).
Cstruct
of_cstruct buf
is the hexadecimal representation of the buffer buf
.
Bigstring
of_bigstring buf
is the hexadecimal representation of the buffer buf
.
to_bigstring t
is the buffer b
such that of_bigstring b
is t
.
Debugging
hexdump h
dumps the hex encoding to stdout in the following format:
00000000: 6865 6c6c 6f20 776f 726c 6420 6865 6c6c hello world hell 00000010: 6f20 776f 726c 640a o world.
This is the same format as emacs hexl-mode, and is a very similar format to hexdump -C. '\t' and '\n' are printed as '.'.in the char column.
print_row_numbers
and print_chars
both default to true
. Setting either to false
does not print the column.
Same as hexdump
except returns a string.
Pretty printing
pp fmt t
will output a human-readable hex representation of t
to the formatter fmt
.