diff --git a/homeassistant/util/__init__.py b/homeassistant/util/__init__.py index de16a2d23d2..6d77f67161d 100644 --- a/homeassistant/util/__init__.py +++ b/homeassistant/util/__init__.py @@ -10,6 +10,7 @@ import random import string from functools import wraps from types import MappingProxyType +from unicodedata import normalize from typing import Any, Optional, TypeVar, Callable, Sequence, KeysView, Union @@ -35,7 +36,7 @@ def sanitize_path(path: str) -> str: def slugify(text: str) -> str: """Slugify a given text.""" - text = text.lower().replace(" ", "_") + text = normalize('NFKD', text).lower().replace(" ", "_") return RE_SLUGIFY.sub("", text) diff --git a/tests/util/test_init.py b/tests/util/test_init.py index 9bfd6ebd6ed..d6d583342d7 100644 --- a/tests/util/test_init.py +++ b/tests/util/test_init.py @@ -30,6 +30,7 @@ class TestUtil(unittest.TestCase): self.assertEqual("test", util.slugify("T-!@#$!#@$!$est")) self.assertEqual("test_more", util.slugify("Test More")) self.assertEqual("test_more", util.slugify("Test_(More)")) + self.assertEqual("test_more", util.slugify("Tèst_Mörê")) def test_repr_helper(self): """Test repr_helper."""