Skip to content

Parse feet and inches when digit separators conflict with foot marks - #1754

Open
angularsen wants to merge 1 commit into
masterfrom
fix/feet-inches-separator-conflict
Open

angularsen wants to merge 1 commit into
masterfrom
fix/feet-inches-separator-conflict

Conversation

@angularsen

Copy link
Copy Markdown
Owner

Follow-up to #1752. CLDR 48 (ICU on Ubuntu 26.04) changed the de-CH digit group separator from ’ to ', which is also a foot mark. On that data, Length.TryParseFeetInches had two problems:

Input (de-CH) Before After
1'000' 6" false 1000.5 ft
5'10" 42.5 ft (510 inches, wrong with no error) 5 ft 10 in

Changes

  • Try each foot mark as the end of the feet part, instead of only the first. This also handles a foot-mark decimal separator in compound input, such as 1'5' 6".
  • When the culture's group separator is a foot mark, require digit groups of the culture's size. .NET number parsing ignores group placement, which is why 5'10 became 510.
  • Cultures whose group separator is not a foot mark keep their existing lenient number parsing.
  • Added tests with a pinned ' separator, plus one using the host's real de-CH separator.

Behavior to review

  • 1'000" stays 1000 inches, and 5'100" is 5100 inches, because those are correctly grouped numbers in that culture. Feet-and-inches notation with a 3-digit inch value is not recognized there.
  • 5'10' in such a culture now returns false; it was 510 ft.
  • Only ParseFeetInches and TryParseFeetInches change. Length.Parse("5'10\"", de-CH) still returns 510 inches.
  • A culture with ' as the decimal separator (none in CLDR, custom cultures only) still reads 5'5" as 5.5 inches.

Verified locally

  • UnitsNet.slnx builds.
  • New tests failed before the parser change (11 failures) and pass after.
  • Full UnitsNet.Tests on net10.0 and net48 pass. Local runs use Windows ICU, so the host-separator test exercises ’ here and ' on CI.

🤖 Generated with Claude Code

CLDR 48 changed the de-CH digit group separator to an ASCII apostrophe,
which is also a foot mark. TryParseFeetInches then returned false for
1'000' 6" because it split at the first apostrophe, and silently parsed
5'10" as 510 inches because number parsing ignores group placement.

Try each foot mark as the end of the feet part, and when the group
separator is a foot mark, require digit groups of the culture's size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98%. Comparing base (096ce0c) to head (2aa698b).

Additional details and impacted files
@@          Coverage Diff           @@
##           master   #1754   +/-   ##
======================================
  Coverage      98%     98%           
======================================
  Files         515     515           
  Lines       24092   24099    +7     
======================================
+ Hits        23692   23701    +9     
+ Misses        400     398    -2     
Flag Coverage Δ
net48 97% <100%> (+<1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant