Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow alternative space characters as group separator when parsing numbers #1007

Merged
merged 2 commits into from Apr 22, 2024

Commits on Apr 18, 2024

  1. Allow alternative space characters as group separator when parsing nu…

    …mbers
    
    The French group separator is `"\u202f"` (narrow non-breaking space),
    but when parsing numbers in the real world, you will most often encounter
    either a regular space character (`" "`) or a non-breaking space character
    (`"\xa0"`).
    
    The issue was partially adressed earlier in python-babel#637,
    but only to allow regular spaces instead of non-breaking spaces `"\xa0"` in
    `parse_decimal`.
    
    This commit goes further by changing both `parse_number` and `parse_decimal`
    to allow any other space character (using the `\s` character class of
    regular expressions) when the group character is itself a space character,
    but is not present in the string to parse.
    
    Unit tests are included.
    ronnix committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    116e566 View commit details
    Browse the repository at this point in the history
  2. Be more specific about which alternative space characters should work…

    … as group symbols
    
    The `\s` character class (or the `string.isspace()` method) could match
    characters like new lines that we probably don’t want to consider as potential
    group symbols in numbers.
    ronnix committed Apr 18, 2024
    Configuration menu
    Copy the full SHA
    181d701 View commit details
    Browse the repository at this point in the history