On Tue, Nov 30, 2010 at 12:40 PM, Michael Foord
<fuzzy...@voidspace.org.uk> wrote:
..
>> If you think non-ASCII digits are not difficult to support, please
>> contribute to the following tracker issues:
>>
>
> Would moving this functionality to the locale module make the issues any
> easier to fix?
>

Sure, if we code it in Python, supporting it will by much easier:

def normalize_digits(s):
    digits = {m.group(1) for m in re.finditer('(\d)', s)}
    trtab = {ord(d): str(unicodedata.digit(d)) for d in digits}
    return s.translate(trtab)

>>> normalize_digits('١٢٣٤.٥٦')
'1234.56'

I am not sure this belongs to the locale module, however.  It seems to
me, something like 'unicodealgo' for unicode algorithms would be more
appropriate.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to