[whatwg] finding a number...

Mikko Rantalainen mikko.rantalainen at peda.net
Wed Dec 13 06:13:10 PST 2006


Charles McCathieNevile wrote:
> On Wed, 13 Dec 2006 13:17:14 +0530, Henri Sivonen <hsivonen at iki.fi> wrote:
>> On Dec 13, 2006, at 08:32, Charles McCathieNevile wrote:
>>> possible *and no simpler* - this is too simple. Maybe assuming you can  
>>> parse numbers out of text is just a dumb idea as a normative part of a  
>>> spec.
>> The attributes always work for any language. For English, the  
>> textContent works as a *bonus*. It isn't that the spec fails to work for  
>> non-English. It is just that a particular *redundant* bonus feature  
>> doesn't work for non-English.
> 
> The problem with this is that it means copying code the natural way  
> doesn't work for some non-english speakers, and they have to read the spec  
> or guess why. [...]

I think that "they have to read the spec" is a bonus, too.

Perhaps the parser could be specified as follows:

regexp for "numeric value" is [0-9 ,.]
scan the numeric value backwards from end
first character matching regexp [,.] is the decimal separator

This would correctly interpret numbers such as

1,251,152.124
634.46
453.436.346,235
23 236 435 123,121

It would fail for numbers such as

1,234,456.789,012
1.234.456,789.012

but that such formats used in any locale?

-- 
Mikko




More information about the whatwg mailing list