package hex

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Hexadecimal encoding.

Char

val of_char : char -> char * char

of_char c is the the hexadecimal encoding of the character c.

val to_char : char -> char -> char

to_char x y is the character correspondong to the xy hexadecimal encoding.

Strings

type t = [
  1. | `Hex of string
]

The type of hexadecimal encodings.

val of_string : ?ignore:char list -> string -> t

of_string s is the hexadecimal representation of the binary string s. If ignore is set, skip the characters in the list when converting. Eg of_string ~ignore:[' '] "a f". The default value of ignore is [])

val to_string : t -> string

to_string h is binary string corresponding to the hexadecimal encoding h. The decoding function will skip whitespaces, tabs and newlines.

Cstruct

val of_cstruct : ?ignore:char list -> Cstruct.t -> t

See of_string

val to_cstruct : t -> Cstruct.t

See to_string

Debugging

val hexdump : ?print_row_numbers:bool -> ?print_chars:bool -> t -> unit

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.

val hexdump_s : ?print_row_numbers:bool -> ?print_chars:bool -> t -> string

Same as hexdump except returns a string.