Ticket #12613: phone2numeric_complete.diff

File phone2numeric_complete.diff, 1.1 KB (added by Gabriel Hurley, 15 years ago)

Adds support for Q and Z in the phone2numeric function.

  • django/utils/text.py

     
    157157
    158158def phone2numeric(phone):
    159159    "Converts a phone number with letters into its numeric equivalent."
    160     letters = re.compile(r'[A-PR-Y]', re.I)
    161     char2number = lambda m: {'a': '2', 'c': '2', 'b': '2', 'e': '3',
    162          'd': '3', 'g': '4', 'f': '3', 'i': '4', 'h': '4', 'k': '5',
    163          'j': '5', 'm': '6', 'l': '5', 'o': '6', 'n': '6', 'p': '7',
    164          's': '7', 'r': '7', 'u': '8', 't': '8', 'w': '9', 'v': '8',
    165          'y': '9', 'x': '9'}.get(m.group(0).lower())
     160    letters = re.compile(r'[A-Z]', re.I)
     161    char2number = lambda m: {'a': '2', 'b': '2', 'c': '2', 'd': '3', 'e': '3',
     162         'f': '3', 'g': '4', 'h': '4', 'i': '4', 'j': '5', 'k': '5', 'l': '5',
     163         'm': '6', 'n': '6', 'o': '6', 'p': '7', 'q': '7', 'r': '7', 's': '7',
     164         't': '8', 'u': '8', 'v': '8', 'w': '9', 'x': '9', 'y': '9', 'z': '9',
     165        }.get(m.group(0).lower())
    166166    return letters.sub(char2number, phone)
    167167phone2numeric = allow_lazy(phone2numeric)
    168168
Back to Top