refactor string escape/unescape methods