merge 2 independent JS string escape methods to 1 and improve it