Implemented an escapeSpecialCharactersInString function.