Maybe you could get more help if you explain what where you trying to do and what were the errors in question . AFAIK, OCaml-strings-as-byte-buffers will work regardless of which compiler is used.
Furthermore, when I was googling to see if any one else had had this issue, I saw that ReadAsBinaryString has been deprecated and that I’m supposed to read the file into an ArrayBuffer instead. I’ll experiment with converting the ArrayBuffer to a string and passing it to the original code, but if that doesn’t work either some sort of #ifdef js_of_ocaml equivalent would be useful.
this stackoverflow comment seems relevant:
poking around the jsoo source I found that runtime/mlString lets me directly create an ocaml string backed by a byte array, I’m now trying to get that playing nicely with gen_js_api, which I believe will solve my issue.
code snippets, for anyone else facing this issue:
this from the js.mli file (processed by gen_js_api):
module ArrayBuffer: sig type t val t_of_js: Ojs.t -> t val t_to_js: t -> Ojs.t val byte_length: t -> int end module Uint8Array: sig type t val t_of_js: Ojs.t -> t val t_to_js: t -> Ojs.t val new_uint8_array: ArrayBuffer.t -> t [@@js.new] val to_string: t -> string [@@js.cast] end
and this from the ml file:
external str_of_uint8Array: Js.Uint8Array.t -> string = "caml_string_of_array" let str_of_arraybuffer buf = let arr = Js.Uint8Array.new_uint8_array buf in str_of_uint8Array arr