[racket] StringBuilder for Racket?
I would use something like
(car (regexp-match #rx#"^[^\0]*" in))
to read a null-terminated byte string from `in'. You'd need a slightly
different regexp depending on whether you want to consume the nul
terminator and allow EOF as a terminator. Change the `#rx#' to `#rx' if
you want to constrain the input to UTF-8-encoded characters, then use
`bytes->string/utf-8' to get from bytes to a string.
To accumulate characters more generally, a string output port is
probably a good choice. Use `open-output-string' to create the port,
`write-string' to add characters to the end, and `get-output-string' to
retrieve the accumulated string.
At Mon, 26 Nov 2012 22:01:15 +0400, Dmitry Pavlov wrote:
> Hello,
>
> I have a trivial task: read a null-terminated string from a stream.
> The size of the string has no predefined limit. How do I do that
> in Racket? I need some resizable thing to store characters,
> like vector<char> in C++ or StringBuilder in C# or Java.
> Does Racket have one?
>
> Best regards,
>
> Dmitry
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users