Show More
@@ -20,6 +20,7 b'' | |||||
20 |
|
20 | |||
21 | import logging |
|
21 | import logging | |
22 | import rhodecode |
|
22 | import rhodecode | |
|
23 | import unicodedata | |||
23 | from rhodecode.lib.type_utils import aslist |
|
24 | from rhodecode.lib.type_utils import aslist | |
24 |
|
25 | |||
25 | log = logging.getLogger(__name__) |
|
26 | log = logging.getLogger(__name__) | |
@@ -133,3 +134,14 b' def ascii_str(str_):' | |||||
133 | if not isinstance(str_, bytes): |
|
134 | if not isinstance(str_, bytes): | |
134 | raise ValueError('ascii_str cannot convert other types than bytes: got: {}'.format(type(str_))) |
|
135 | raise ValueError('ascii_str cannot convert other types than bytes: got: {}'.format(type(str_))) | |
135 | return str_.decode('ascii') |
|
136 | return str_.decode('ascii') | |
|
137 | ||||
|
138 | ||||
|
139 | def convert_special_chars(str_): | |||
|
140 | """ | |||
|
141 | trie to replace non-ascii letters to their ascii representation eg:: | |||
|
142 | ||||
|
143 | `żołw` converts into `zolw` | |||
|
144 | """ | |||
|
145 | value = safe_str(str_) | |||
|
146 | converted_value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode() | |||
|
147 | return converted_value |
General Comments 0
You need to be logged in to leave comments.
Login now