Skip to content

Instantly share code, notes, and snippets.

@Et7f3
Created April 15, 2019 14:29
Show Gist options
  • Save Et7f3/65bf2fd0578dd3bb0cea5ce0d629a031 to your computer and use it in GitHub Desktop.
Save Et7f3/65bf2fd0578dd3bb0cea5ce0d629a031 to your computer and use it in GitHub Desktop.
Man ascii generator for windows
(**
compiled with
ocamlopt ascii.ml -o ascii
or
ocamlopt.opt.exe ./ascii.ml -o ./ascii.exe
*)
let () =
Printf.printf "oct | dec | hex | char%10soct | dec | hex | char\n" " "
let () =
let to_char_string = function
127 -> "DEL"
| i -> i |> char_of_int |> Char.escaped
in
for i = 32 to 80 do
let p = Printf.printf "%3o %3d %3X %4s\t\t%3o %3d %3X %4s\n" i i i (char_of_int i |> Char.escaped) in
let i = i + 47 in
p i i i (i |> to_char_string)
done
let () = flush stdout
let _ = input_char stdin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment