Bugs/2674/utf8

It's fixing #2674. It also significantly increases performance of UTF encoding.
Ok.. I see you already are using this trick :)