Opened 11 years ago
Closed 8 years ago
#10843 closed defect (patchwelcome)
dojo.number.format does not support spaces
Reported by: | clinejm | Owned by: | Adam Peller |
---|---|---|---|
Priority: | high | Milestone: | 1.9 |
Component: | Core | Version: | 1.4.0 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
If you supply a pattern that includes spaces the formatter will stop after the first space:
<input dojotype="dijit.form.NumberTextBox?" constraints="{pattern: '# ##0.00'}" id="testText" name="testText"/>
an input of 123456789 will result in:
123,456,789 ###,00
I've tested in 1.3 and 1.4 with the same results.
Change History (8)
comment:1 Changed 11 years ago by
comment:2 Changed 11 years ago by
Milestone: | tbd → 1.5 |
---|---|
Owner: | changed from anonymous to Adam Peller |
Status: | new → assigned |
Not sure this example was there when dojo.number was implemented, but it certainly appears to be a bug. I suppose any character not on the special list should be passed through.
comment:3 Changed 11 years ago by
a testcase:
Index: number.js =================================================================== --- number.js (revision 21565) +++ number.js (working copy) @@ -330,6 +330,8 @@ //change decimal places t.is("-1\xa0000,100", dojo.number.format(-1000.1, {places:3, locale: "fr-fr"})); t.is("-1,000.100", dojo.number.format(-1000.1, {places:3, locale: "en-us"})); + + t.is("1 234,57", dojo.number.format(1234.57, {pattern: "# ##0.00", locale: "fr-fr"})); } }, {
comment:4 Changed 11 years ago by
I'm starting to doubt this is going to make 1.5. I trust you're able to work around this?
comment:5 Changed 11 years ago by
comment:6 Changed 11 years ago by
Milestone: | 1.5 → future |
---|
comment:7 Changed 11 years ago by
note that characters like '.' and ',' still have special meaning and are localized, according to the spec. ' ' for a thousands separator can be achieved by choosing a locale which supports this, like fr, or perhaps by calling dojo.number._formatAbsolute directly and providing explicit separator characters to override the localized behavior (should this be made public?)
comment:8 Changed 8 years ago by
Component: | General → Core |
---|---|
Milestone: | future → 1.9 |
Resolution: | → patchwelcome |
Status: | assigned → closed |
A patch would be welcomed to fix this. For now, closing due to lack of activity in creating a solution for this.
The example pattern is specifically referenced in http://www.unicode.org/reports/tr35/#Number_Format_Patterns which dojo.number.format references in the documentation