Hi,
what would be the best way to convert
only a part of a byte vector (interpreted as
UTF-8) to string?
Let's say that I have a big buffer,
(define buffer (make-u8vector 1024))
which contains some message
(define n (recv! sock buffer))
I'd like to get only the first n bytes of buffer.
I initially thought that this would do:
(utf8->string (make-shared-array buffer list `(0 ,(- n 1))))
(the utf8->string comes from ((rnrs) #:version (6)) module)
However, it failed (having expected byte-vector).
Another option would be to use
(substring (utf8->string buffer 0 n))
This one works, but according to the manual, the
string is "newly allocated", so it's unnecessary overhead.
What would be the best solution?
TIA
M