brr icon indicating copy to clipboard operation
brr copied to clipboard

`Tarray.{of,to}_binary_jstr`: unclear doc, dead link

Open nojb opened this issue 9 months ago • 2 comments

Tarray.{of,to}_binary_jstr mention "Javascript binary string", but the link is dead and searching "Javascript binary string" does not yield much (the concept appears to have been deprecated in favour of typed arrays).

Is it the case that the Jstr.t in these functoins encode one byte per UTF-16 unit?

Thanks for the nice library! (If only it had existed when gen_js_api was introduced, maybe we could have avoided having two incompatible types for OCaml/JS FFI).

nojb avatar May 24 '25 12:05 nojb

Is it the case that the Jstr.t in these functoins encode one byte per UTF-16 unit?

Answering to myself: yes, looks like it is the case:

https://github.com/dbuenzli/brr/blob/25f991e9021c0c5a306e2605dd1148fb3334f499/src/brr.ml#L734-L745

I suspect that Tarray.to_binary_jstr is the composition fun x -> Jstr.binary_of_octets (Tarray.to_string x). If that's the case, it could be useful to mention this in the docstring. Otherwise, it may be good to explain the difference.

Anyway, nothing left to do here. Sorry for the noise!

nojb avatar May 25 '25 07:05 nojb

Well the doc link should be fixed or the definition of a binary string be inlined. It seems that indeed the thing vanished from MDN. The only (indirect) reference I can find now is https://w3c.github.io/FileAPI/#packaging-data

dbuenzli avatar May 25 '25 12:05 dbuenzli

Thanks!

nojb avatar Jul 21 '25 19:07 nojb

Thanks, report about dangling docs are particularly appreciated.

dbuenzli avatar Jul 21 '25 19:07 dbuenzli