Make it work with utf8 and ascii encoded streams, and object mode

I also added tests ;)