1 # -*- coding: utf-8 -*-
3 from fnpdjango.utils.text import char_map
6 # Specifies diacritics order.
7 # Default order is zero, max is 9
16 order = char_order.get(char, 0)
17 return "%s~%d" % (char_map[char], order)
24 Turns Unicode into ASCII-sortable str
28 >>> sortify('a a') < sortify('aa') < sortify('ą') < sortify('b')
31 >>> sortify('ź') < sortify('ż')
36 if not isinstance(value, unicode):
37 value = unicode(value, 'utf-8')
39 # try to replace chars
40 value = re.sub('[^a-zA-Z0-9\\s\\-]', replace_char, value)
42 value = re.sub(r'[^a-z0-9~]+', ' ', value)
44 return value.encode('ascii', 'ignore')