Module Hex
Hexadecimal encoding.
Hex defines hexadecimal encodings for characters, strings and Cstruct.t buffers.
Characters
Strings
val of_string : ?ignore:char list -> string -> tof_string sis the hexadecimal representation of the binary strings. Ifignoreis set, skip the characters in the list when converting. Egof_string ~ignore:[' '] "a f". The default value ofignoreis[]).
val to_string : t -> stringto_string tis the binary stringssuch thatof_string sist.
Bytes
val of_bytes : ?ignore:char list -> bytes -> tof_bytes sis the hexadecimal representation of the binary strings. Ifignoreis set, skip the characters in the list when converting. Egof_bytes ~ignore:[' '] "a f". The default value ofignoreis[]).
val to_bytes : t -> bytesto_bytes tis the binary stringssuch thatof_bytes sist.
Cstruct
val of_cstruct : ?ignore:char list -> Cstruct.t -> tof_cstruct bufis the hexadecimal representation of the bufferbuf.
val to_cstruct : t -> Cstruct.tto_cstruct tis the bufferbsuch thatof_cstruct bist.
Bigstring
val of_bigstring : ?ignore:char list -> Cstruct.buffer -> tof_bigstring bufis the hexadecimal representation of the bufferbuf.
val to_bigstring : t -> Cstruct.bufferto_bigstring tis the bufferbsuch thatof_bigstring bist.
Debugging
val hexdump : ?print_row_numbers:bool -> ?print_chars:bool -> t -> unithexdump hdumps 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_numbersandprint_charsboth default totrue. Setting either tofalsedoes not print the column.
val hexdump_s : ?print_row_numbers:bool -> ?print_chars:bool -> t -> stringSame as
hexdumpexcept returns a string.
Pretty printing
val pp : Stdlib.Format.formatter -> t -> unitpp fmt twill output a human-readable hex representation oftto the formatterfmt.
val show : t -> stringshow twill return a human-readable hex representation oftas a string.