With a test.ml that contains just failwith “тест”, my guard is lowered by this printing as shown here, and then in a real program it prints as string escapes. What’s responsible for that?
$ ocaml test.ml
Exception: Failure "тест".
$ ocaml -I +unix unix.cma test.ml
Exception: Failure "тест".
$ ocamlc test.ml && ./a.out
Fatal error: exception Failure("тест")
$ ocamlc -I +unix unix.cma test.ml && ./a.out
Fatal error: exception Failure("\209\130\208\181\209\129\209\130")
Unix registers a callback, but copying that into this test still doesn’t breaking printing, so my guess is that some C stub changes the printing.
I’ve found a close workaround in
let () =
Printexc.register_printer (function
| Failure msg -> Some (Printf.sprintf "Failure(%s)" msg)
| _ -> None)
What I’d like is sadly a locale, or%Sescaping everything except for some graphemes that I consider to be printable, so I need register_printer in any case. I just wonder what’s changing the printer above.