: NATIVE_CHARACTER = struct
type t = char
let of_native_char x = Some x
let of_int x =
try Some (char_of_int x) with _ -> None
let to_int = int_of_char
let compare = Char.compare
let size _ = 1
let is_print t = ' ' <= t && t <= '~'
let to_native_string x = String.make 1 x
let to_string_hum x =
if is_print x then String.make 1 x
else sprintf "0x%2x" (int_of_char x)
let write_to_native_string c ~buf ~index =
try buf.[index] <- c; return 1
with _ -> fail `out_of_bounds
let read_from_native_string ~buf ~index =
try Some (buf.[index], 1)
with _ -> None
let is_whitespace =
function ' ' | '\t' | '\r' | '\n' -> true | _ -> false
end