Refactoring special character handling.