Reading UTF8 string from a stream

I just ran into a case where I need to read a UTF8 string from an InputStream. The String class has nice UTF8 support, but between that and the InputStream class I can’t find a simple way to read one except by using a MemoryBlock as an intermediate step. I’m probably just missing something, but if not, this would be a nice addition. Maybe a readUTF8String member of the InputStream class that takes an optional length argument (reads to a null if omitted)?

…Oh yeah, and of course you’d need the corresponding OutputStream method that would let you control writing with or without the null terminator. This would you read/write length-prefixed strings too, which are preferred in some environments (e.g. .NET).

Good request, I’ll have a think about that.

Great. Thanks!

While we’re on the subject of streams, heres another feature request. I’m having to implement my own InputStream/OuputStream -derived classes to go with the StreamingSocket class. I have a constructor arg that indicates the blocking behavior, which is considered by the overridden read and write methods. It seems like this could be something useful to have in the library for consistency.