LANG-935: Possible performance improvement on string escape functions. Thanks to Fabian Lange and Thomas Neidhart.