Repository navigation
Commit d981c4c
Parse feet and inches when digit separators conflict with foot marks (#1754)
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](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent 096ce0c commit d981c4c
2 files changed
Lines changed: 93 additions & 20 deletions
File tree
- UnitsNet.Tests/CustomCode
- UnitsNet/CustomCode/Quantities
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
92 | 144 | | |
93 | 145 | | |
94 | 146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
79 | 85 | | |
80 | | - | |
| 86 | + | |
81 | 87 | | |
82 | 88 | | |
83 | 89 | | |
84 | 90 | | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
| 91 | + | |
89 | 92 | | |
90 | | - | |
91 | | - | |
92 | | - | |
| 93 | + | |
| 94 | + | |
93 | 95 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
| 96 | + | |
| 97 | + | |
100 | 98 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
107 | 111 | | |
108 | 112 | | |
109 | 113 | | |
110 | 114 | | |
111 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
112 | 133 | | |
113 | 134 | | |
114 | 135 | | |
| |||
0 commit comments