Skip to content

Parser function formatnum doesn't handle alternative digits (South Asian scripts, West Arabic numerals etc.) #425

Description

@kristian-clausal

In #424 I fixed some issues with formatnum and introduced localization configuration, but I couldn't figure out a simple way (with an authorative Python-friendly source) to do alternative digit localization correctly.

formatnum is a parserfn that does basically two things:

  1. takes a basic "English programming" formatted number string like 123456789.123 and turns it into a formatted string (123,456,789.123 in English, 123.456.789,123 in French and 12,34,56,789.123 in Hindi, if we used Arabic numerals because alternative digits aren't implemented yet).
  2. takes a previously formatted string and returns the "English programming" formatted number string. Basically, it removes the thousands separators and should (if it was implemented) turns alternative digits back to Arabic numerals.

There's some information about alternative digits that should be available in standard library Python... Except it's bugged: python/cpython#124969

Additionally, the data accessible with locale.ALT_DIGITS is... just a list of actual "numbers"; a list (or a null-separated array of strings in C, which is where the bug lies with Python) of strings that correspond exactly to "0", "1", "2"... and "15", "16" etc. up to "99".

It doesn't tell you how to do the conversion, it's just a list of the first hundred positive integers.

This will be on the backburner until a later version of Python, at the very least.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions