1 # -*- coding: utf-8 -*-
3 from slughifi import char_map
6 # Specifies diacritics order.
7 # Default order is zero, max is 9
15 if char_map.has_key(char):
16 order = char_order.get(char, 0)
17 return "%s~%d" % (char_map[char], order)
24 Turns Unicode into ASCII-sortable str
28 >>> sortify('aa') < sortify('a a') < 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\\-]{1}', replace_char, value)
42 value = re.sub(r'[^a-z0-9~]+', '|', value)
44 return value.encode('ascii', 'ignore')