Optimize escaping string code
Use charCodeAt instead of charAt