Ticket #2276: defaultfilters.py.3.diff

File defaultfilters.py.3.diff, 740 bytes (added by nkeric, 18 years ago)

output string should be utf-8 encoded as input string

  • django/template/defaultfilters.py

     
    6565
    6666def slugify(value):
    6767    "Converts to lowercase, removes non-alpha chars and converts spaces to hyphens"
    68     value = re.sub('[^\w\s-]', '', value).strip().lower()
    69     return re.sub('[-\s]+', '-', value)
     68    decoded_value = unicode(value, 'utf-8')
     69    p = re.compile('[^\w\s-]', re.UNICODE)
     70    decoded_value = re.sub(p, '', decoded_value).strip().lower()
     71    decoded_value = re.sub('[-\s]+', '-', decoded_value)
     72    return decoded_value.encode('utf-8')
    7073
    7174def stringformat(value, arg):
    7275    """
Back to Top