diff --git a/rhodecode/lib/str_utils.py b/rhodecode/lib/str_utils.py --- a/rhodecode/lib/str_utils.py +++ b/rhodecode/lib/str_utils.py @@ -20,6 +20,7 @@ import logging import rhodecode +import unicodedata from rhodecode.lib.type_utils import aslist log = logging.getLogger(__name__) @@ -133,3 +134,14 @@ def ascii_str(str_): if not isinstance(str_, bytes): raise ValueError('ascii_str cannot convert other types than bytes: got: {}'.format(type(str_))) return str_.decode('ascii') + + +def convert_special_chars(str_): + """ + trie to replace non-ascii letters to their ascii representation eg:: + + `żołw` converts into `zolw` + """ + value = safe_str(str_) + converted_value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode() + return converted_value