@@ -49,19 +49,17 @@ do
50### Serialize a `String` as UTF8
50### Serialize a `String` as UTF8
52−Encode a `String` as UTF8 with a length prefix in a
52+Encode a `String` as UTF8 with a length prefix.
53−way that's compatible with the
53+
54−[`Binary.Put.putStringUtf8`](https://hackage.haskell.org/package/binary/docs/Data-Binary-Put.html#v:putStringUtf8)
54+We give this as an example, rather than supporting it in the library, because
55−function from the Haskell
55+it depends on
56−[__binary__](https://hackage.haskell.org/package/binary)
58−Uses [`Data.TextEncoding.encodeUtf8`](https://pursuit.purescript.org/packages/purescript-text-encoding/docs/Data.TextEncoding#v:encodeUtf8).
56+[`Data.TextEncoding.encodeUtf8`](https://pursuit.purescript.org/packages/purescript-text-encoding/docs/Data.TextEncoding#v:encodeUtf8).
59```purescript
58```purescript
60putStringUtf8 :: forall m. (MonadEffect m) => String -> PutM m Unit
59putStringUtf8 :: forall m. (MonadEffect m) => String -> PutM m Unit
61putStringUtf8 s = do
60putStringUtf8 s = do
62 let stringbuf = Data.ArrayBuffer.Typed.buffer $ Data.TextEncoding.encodeUtf8 s
61 let stringbuf = Data.ArrayBuffer.Typed.buffer $ Data.TextEncoding.encodeUtf8 s
63− -- Put a 64-bit big-endian length prefix for the length of the utf8 string, in bytes.
62+ -- Put a 32-bit big-endian length prefix for the length of the utf8 string, in bytes.
65 putUint32be $ Data.Uint.fromInt $ Data.ArrayBuffer.byteLength stringbuf
63 putUint32be $ Data.Uint.fromInt $ Data.ArrayBuffer.byteLength stringbuf
66 putArrayBuffer stringbuf
64 putArrayBuffer stringbuf
@@ -77,6 +75,7 @@ way that's compatible with the
77from the Haskell
75from the Haskell
78[__binary__](https://hackage.haskell.org/package/binary)
76[__binary__](https://hackage.haskell.org/package/binary)
80```purescript
79```purescript
81putArrayInt32 :: forall m. (MonadEffect m) => Array Int -> PutM m Unit
80putArrayInt32 :: forall m. (MonadEffect m) => Array Int -> PutM m Unit
82putArrayInt32 xs = do
81putArrayInt32 xs = do