I am encoding data in the browser using CBOR on jsoo and want to send the rensult to my server. CBOR.encode returns a string and I want to send that over websocket but when I end up with garbled data, probably re-encoded because the input string is not UTF-8.
There is a function
Websocket.send_buffer : Typed_array.arrayBuffer Js.t -> unit Js.meth but I don’t know how to go from my OCaml string to a value of that type. I will also need to do the opposite conversion but
Typed_array.String.of_arrayBuffer : arrayBuffer Js.t -> string seems appropriate.
Any idea about the steps to follow?