-# -*- coding: utf-8 -*-
import re
from fnpdjango.utils.text import char_map
# Specifies diacritics order.
# Default order is zero, max is 9
char_order = {
- u'ż': 1, u'Ż': 1,
+ 'ż': 1, 'Ż': 1,
}
"""
- if not isinstance(value, unicode):
- value = unicode(value, 'utf-8')
+ if not isinstance(value, str):
+ value = str(value, 'utf-8')
# try to replace chars
value = re.sub('[^a-zA-Z0-9\\s\\-]', replace_char, value)
value = value.lower()
value = re.sub(r'[^a-z0-9~]+', ' ', value)
- return value.encode('ascii', 'ignore')
+ return value.encode('ascii', 'ignore').decode('ascii')