Maui icon indicating copy to clipboard operation
Maui copied to clipboard

Parse double precision using InvariantCulture

Open stephenquan opened this issue 7 months ago • 2 comments

Description of Change

Parse a double using InvariantCulture to avoid issues when CurrentCulture changes, such as to 'ar-AR'.

Linked Issues

  • Fixes https://github.com/CommunityToolkit/Maui/issues/2721
  • Fixes https://github.com/CommunityToolkit/Maui/issues/2665

PR Checklist

  • [x] Has a linked Issue, and the Issue has been approved(bug) or Championed (feature/proposal)
  • [x] Has tests (if omitted, state reason in description)
  • [ ] Has samples (omitted, since this is a minor change)
  • [x] Rebased on top of main at time of PR
  • [x] Changes adhere to coding standard
  • [ ] Documentation created or updated: (no change)

Additional information

None

stephenquan avatar Jun 16 '25 04:06 stephenquan

@VladislavAntonyuk I've pushed a new commit that introduces the Culture property for both MathExpressionConverter and MultiMathExpressionConverter. Ideally, this should remain set to the default InvariantCulture. That said, I've tested it with several European cultures - such as "fr-FR", which uses a comma as the decimal separator - and it performs as expected.

The original issue, however, supporting Arabic as the numeric culture, is currently out of scope. Properly handling Arabic number formatting would require a significantly more robust parsing strategy to accommodate all relevant symbols. The example below highlights the mapping we need to consider to convert Arabic number format to Western number format (including swapping the decimal with the comma).

🧮 Arabic Number Formatting Summary (Culture: ar-SA)

Component Arabic Format Unicode Notes
Digits Arabic-Indic (٠١٢٣٤٥٦٧٨٩) U+0660–U+0669 Replaces Western digits (0–9)
Decimal Separator Arabic decimal ٫ U+066B Replaces the Western .
Thousands Separator Arabic comma ٬ U+066C Replaces the Western ,
Minus Sign Unicode minus U+2212 Replaces the Western Hyphen-minus -

stephenquan avatar Nov 12 '25 23:11 stephenquan

Adding https://github.com/CommunityToolkit/Maui/issues/2665

stephenquan avatar Nov 16 '25 07:11 stephenquan