* refactoring escape character parsing to reduce code repetition