I had to deal with UTF-8 data that comes as a binary stream and sometimes encountered gibberish data along with the output.

The reason is because I use buffer.toString() which doesn't handle incomplete UTF-8 sequence. The fix is to use StringDecoder instead. The API docs didn't say much about StringDecoder so I wrote a post about it. Hope that this can be useful.
Shared publiclyView activity