make it work with utf8 and ascii encoded streams