Re: Converting a part of byte vector to UTF-8 string

2014-01-15 Thread Mark H Weaver
Panicz Maciej Godek writes: > Your solution seems reasonable, but I have found another way, which > lead me to some new problems. > I realised that since sockets are ports in guile, I could process them > with the plain "read" (which is what I have been using them for > anyway). > > However, this

Re: Converting a part of byte vector to UTF-8 string

2014-01-15 Thread Panicz Maciej Godek
hello :) [...] But I have a give a warning again, when you try to avoid allocation > overhead, you have to face the risk of the side-effect. To me, I'd > prefer pure-functional. ;-P > > Your solution seems reasonable, but I have found another way, which lead me to some new problems. I realised th

Re: Converting a part of byte vector to UTF-8 string

2014-01-14 Thread Nala Ginrut
hi there! On Tue, 2014-01-14 at 00:17 +0100, Panicz Maciej Godek wrote: > 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. > Actually, substring is COW(copy-on

Converting a part of byte vector to UTF-8 string

2014-01-13 Thread Panicz Maciej Godek
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 initial