I get a UTF8 string from C++ and want to copy it to OCaml side. Right now I’m using standard string
type. And printing of these strings is not fancy.
I heard that visualization of unicode string somehow depend on the destination where I’m printing it. But my understanding is very vague and I’m not sure. Example
main.ml
type t = A of string [@@deriving show]
let p = A "(\208\149\208\178\208\179\208\181\208\189\208\184\208\185)"
let () =
let (A s) = p in
print_endline s
;;
let () = Format.printf "%a\n%!" pp p
And I get
(Евгений)
(Main.A "(\208\149\208\178\208\179\208\181\208\189\208\184\208\185)")
Clearly Format is not so fancy in printing.
Questions:
- Which alternatives we have to store UTF8 string as OCaml value?
- Is there any ppx_deriving special attribute that repairs printing of Unicode? Or Format-specific one?