Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Adding support for number formating to the JS i18n API. (issue7129051)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
c...@chromium.org  
View profile  
 More options Jun 9 2011, 6:40 pm
From: c...@chromium.org
Date: Thu, 09 Jun 2011 22:40:12 +0000
Local: Thurs, Jun 9 2011 6:40 pm
Subject: Adding support for number formating to the JS i18n API. (issue7129051)
Reviewers: Jungshik Shin, Mads Ager,

Message:
Jungshink: please take a look at ICU calls and overall logic.

Mads:
I can't use internal methods so I had to make some interesting choices on  
how to
detect NaN in C++ code.
Could you take a look at JSNumberFormat method where I eval('NaN') to get  
actual
value and see if it makes sense.
 From some forum posts it seems v8 uses 2 values for NaN (-NaN and NaN).  
True?

Description:
Adding support for number formating to the JS i18n API.

This is the last part of the API that belongs in public spec.

Methods supported:
- format
- derive

Options supported:
- style (decimal, scientific, currency and percent)
- pattern
- skeleton

TEST= Visit i18n.kaziprst.org/numberformat.html

Please review this at http://codereview.chromium.org/7129051/

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
   M     src/extensions/experimental/experimental.gyp
   M     src/extensions/experimental/i18n-extension.cc
   M     src/extensions/experimental/i18n.js
   A     src/extensions/experimental/number-format.h
   A     src/extensions/experimental/number-format.cc


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
a...@chromium.org  
View profile  
 More options Jun 10 2011, 3:25 am
From: a...@chromium.org
Date: Fri, 10 Jun 2011 07:25:30 +0000
Local: Fri, Jun 10 2011 3:25 am
Subject: Re: Adding support for number formating to the JS i18n API. (issue7129051)
This version of NaN handling is not going to work since NaN is not equal to
anything. The rest of the V8 usage looks fine.

http://codereview.chromium.org/7129051/diff/3001/src/extensions/exper...
File src/extensions/experimental/number-format.cc (right):

http://codereview.chromium.org/7129051/diff/3001/src/extensions/exper...
src/extensions/experimental/number-format.cc:90: if (value == nan_) {
This does not work. NaN is not equal to anything so this should always
be false. Have you tested this?

You do need a is_nan method here. Most platforms provide one directly
and windows has is_nan_. Can you introduce a i18n-extension-utils.h file
that does the right platform #ifdef magic to make a is_nan method
available on all platforms?

http://codereview.chromium.org/7129051/diff/3001/src/extensions/exper...
File src/extensions/experimental/number-format.h (right):

http://codereview.chromium.org/7129051/diff/3001/src/extensions/exper...
src/extensions/experimental/number-format.h:58: void* param);
Indentation is a bit off.

http://codereview.chromium.org/7129051/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
a...@chromium.org  
View profile  
 More options Jun 10 2011, 3:29 am
From: a...@chromium.org
Date: Fri, 10 Jun 2011 07:29:46 +0000
Local: Fri, Jun 10 2011 3:29 am
Subject: Re: Adding support for number formating to the JS i18n API. (issue7129051)
Doesn't ICU deal with NaN on its own? I would have guessed that ICU would  
give
you either "NaN" or some special value signaling that it was asked to  
format a
NaN value? If it does that will simplify the problem because you let ICU  
deal
with it and just switch on the result from the ICU formatting.

http://codereview.chromium.org/7129051/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nebojša Ćirić  
View profile  
 More options Jun 10 2011, 12:10 pm
From: Nebojša Ćirić <c...@chromium.org>
Date: Fri, 10 Jun 2011 09:10:05 -0700
Local: Fri, Jun 10 2011 12:10 pm
Subject: Re: Adding support for number formating to the JS i18n API. (issue7129051)

10. јун 2011. 00.25, <a...@chromium.org> је написао/ла:

> This version of NaN handling is not going to work since NaN is not equal to
> anything. The rest of the V8 usage looks fine.

It seemed that NaN can take only 2 values in v8 world - see
http://code.google.com/p/v8/issues/detail?id=1101

> http://codereview.chromium.**org/7129051/diff/3001/src/**
> extensions/experimental/**number-format.cc<http://codereview.chromium.org/7129051/diff/3001/src/extensions/exper...>
> File src/extensions/experimental/**number-format.cc (right):

> http://codereview.chromium.**org/7129051/diff/3001/src/**
> extensions/experimental/**number-format.cc#newcode90<http://codereview.chromium.org/7129051/diff/3001/src/extensions/exper...>
> src/extensions/experimental/**number-format.cc:90: if (value == nan_) {
> This does not work. NaN is not equal to anything so this should always
> be false. Have you tested this?

I did with actual NaN from JavaScript and non-number values like strings...

> You do need a is_nan method here. Most platforms provide one directly
> and windows has is_nan_. Can you introduce a i18n-extension-utils.h file
> that does the right platform #ifdef magic to make a is_nan method
> available on all platforms?

I'll try ICU approach.

> http://codereview.chromium.**org/7129051/diff/3001/src/**
> extensions/experimental/**number-format.h<http://codereview.chromium.org/7129051/diff/3001/src/extensions/exper...>
> File src/extensions/experimental/**number-format.h (right):

> http://codereview.chromium.**org/7129051/diff/3001/src/**
> extensions/experimental/**number-format.h#newcode58<http://codereview.chromium.org/7129051/diff/3001/src/extensions/exper...>
> src/extensions/experimental/**number-format.h:58: void* param);
> Indentation is a bit off.

> http://codereview.chromium.**org/7129051/<http://codereview.chromium.org/7129051/>

--
Nebojša Ćirić

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lasse R.H. Nielsen  
View profile  
 More options Jun 10 2011, 2:21 pm
From: "Lasse R.H. Nielsen" <l...@chromium.org>
Date: Fri, 10 Jun 2011 20:21:42 +0200
Local: Fri, Jun 10 2011 2:21 pm
Subject: Re: [v8-dev] Re: Adding support for number formating to the JS i18n API. (issue7129051)

On Fri, Jun 10, 2011 at 18:10, Nebojša Ćirić <c...@chromium.org> wrote:

> 10. јун 2011. 00.25, <a...@chromium.org> је написао/ла:

>> This version of NaN handling is not going to work since NaN is not equal
>> to
>> anything. The rest of the V8 usage looks fine.

> It seemed that NaN can take only 2 values in v8 world -
> see http://code.google.com/p/v8/issues/detail?id=1101

We don't make any promises, but yes, currently we only ever create a
SNaN with zero payload, possibly signed (simply because negation on
doubles doesn't check for NaN).

Don't rely on it unless there is a good reason, though. It's not
guaranteed to stay that way.
And if you use is_nan (which you must, because NaN != NaN, even if
it's the same NaN representation), it won't matter.

/L
--
Lasse R.H. Nielsen
l...@chromium.org


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
c...@chromium.org  
View profile  
 More options Jun 14 2011, 5:46 pm
From: c...@chromium.org
Date: Tue, 14 Jun 2011 21:46:21 +0000
Local: Tues, Jun 14 2011 5:46 pm
Subject: Re: Adding support for number formating to the JS i18n API. (issue7129051)
Sorry, I was away Fri-Mon.

Not ready for another review.

I'll add currencyCode (to match update in the docs) to the settings and  
then ask
for another round.

http://codereview.chromium.org/7129051/diff/3001/src/extensions/exper...
File src/extensions/experimental/number-format.cc (right):

http://codereview.chromium.org/7129051/diff/3001/src/extensions/exper...
src/extensions/experimental/number-format.cc:90: if (value == nan_) {
ICU can handle NaN properly so I've removed hacky code.

On 2011/06/10 07:25:30, Mads Ager wrote:

> This does not work. NaN is not equal to anything so this should always
be false.
> Have you tested this?
> You do need a is_nan method here. Most platforms provide one directly
and
> windows has is_nan_. Can you introduce a i18n-extension-utils.h file
that does
> the right platform #ifdef magic to make a is_nan method available on
all
> platforms?

http://codereview.chromium.org/7129051/diff/3001/src/extensions/exper...
File src/extensions/experimental/number-format.h (right):

http://codereview.chromium.org/7129051/diff/3001/src/extensions/exper...
src/extensions/experimental/number-format.h:58: void* param);
On 2011/06/10 07:25:30, Mads Ager wrote:

> Indentation is a bit off.

Done.

http://codereview.chromium.org/7129051/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
c...@chromium.org  
View profile  
 More options Jun 15 2011, 6:19 pm
From: c...@chromium.org
Date: Wed, 15 Jun 2011 22:19:00 +0000
Subject: Re: Adding support for number formating to the JS i18n API. (issue7129051)
PTAL

I did one more pass over the code to fix couple of skeleton issues.

I also added currencyCode setting in i18n.js. If present it will override  
region
ID inferred currency code (in native code).

http://codereview.chromium.org/7129051/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
a...@chromium.org  
View profile  
 More options Jun 16 2011, 5:55 am
From: a...@chromium.org
Date: Thu, 16 Jun 2011 09:55:07 +0000
Local: Thurs, Jun 16 2011 5:55 am
Subject: Re: Adding support for number formating to the JS i18n API. (issue7129051)
 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
js...@chromium.org  
View profile  
 More options Jun 16 2011, 2:08 pm
From: js...@chromium.org
Date: Thu, 16 Jun 2011 18:08:19 +0000
Local: Thurs, Jun 16 2011 2:08 pm
Subject: Re: Adding support for number formating to the JS i18n API. (issue7129051)

http://codereview.chromium.org/7129051/diff/11004/src/extensions/expe...
File src/extensions/experimental/i18n.js (right):

http://codereview.chromium.org/7129051/diff/11004/src/extensions/expe...
src/extensions/experimental/i18n.js:267:
/^[a-zA-Z]{3}$/.test(settings['currencyCode'])) {
Is it your intent to allow mixed-case 3-letter code?

http://codereview.chromium.org/7129051/diff/11004/src/extensions/expe...
src/extensions/experimental/i18n.js:268: cleanSettings['currencyCode'] =
settings['currencyCode'].toUpperCase();
It looks like it's assumed that v8's toUpperCase will remain always
locale-independent (i.e. acting like POSIX locale : [a-z] => [A-Z]).  At
least, add a comment about that.

http://codereview.chromium.org/7129051/diff/11004/src/extensions/expe...
File src/extensions/experimental/number-format.cc (right):

http://codereview.chromium.org/7129051/diff/11004/src/extensions/expe...
src/extensions/experimental/number-format.cc:220: // It affects currency
formatters only.
Pls, add a comment that |region| here is actually a full-blown locale id
in the form of 'und_' + region ID. An alternative is: 1) do not prepend
'und_' on the JavaScript-side 2) add 'und_' at the last moment inside
GetCurrencyCode().

http://codereview.chromium.org/7129051/diff/11004/src/extensions/expe...
src/extensions/experimental/number-format.cc:227: }
What if the locale id (icu_locale) itself has a currency code specified
(with '-u-cu-FOO')? We have to determine the priority order among three
possible sources.

http://codereview.chromium.org/7129051/diff/11004/src/extensions/expe...
src/extensions/experimental/number-format.cc:244: // UChar
representation of \x00A4 currency symbol.
nit: \x00A4 => U+00A4

http://codereview.chromium.org/7129051/diff/11004/src/extensions/expe...
src/extensions/experimental/number-format.cc:245: const UChar
currency_symbol = 0xA4;
nit: Didn't any complier complain?  Perhaps, it's safer to add 'u'.

http://codereview.chromium.org/7129051/diff/11004/src/extensions/expe...
src/extensions/experimental/number-format.cc:249: // Find how many 0xA4
are there. There is at least one.
nit: U+00A4

BTW, the code below assumes that a skeleton has one or more U+00A4's in
a row. What if there is an intervening character between them?
Shouldn't we use a regex matcher (to match 1 to 3 (or 4) U+00A4's in a
row? Actually, using regex seems to be an overkill. Perhaps, after
finding |end_index}, you can walk from index to end_index to make sure
there' no other character in-between.  If there is, you can reject the
skeleton as invalid.

http://codereview.chromium.org/7129051/diff/11004/src/extensions/expe...
src/extensions/experimental/number-format.cc:268:
icu::NumberFormat::createPercentInstance(icu_locale, *status));
no support for scientific with a skeleton?

http://codereview.chromium.org/7129051/diff/11004/src/extensions/expe...
src/extensions/experimental/number-format.cc:279: // Copy important
information from skeleton to the new formatter.
I wonder if there's anything else to pass from skeleton.  e.g.
roundingIncrement (http://goo.gl/RU4qG )?

roundingMode cannot be set via a pattern. So, we can't support in
skeleton, but roundingIncrement can be set via a pattern....

http://codereview.chromium.org/7129051/diff/11004/src/extensions/expe...
src/extensions/experimental/number-format.cc:311: // or provided region
id.
Here again, it's confusing to say 'region id' because it's more than
that. ('und_' + region ID).

http://codereview.chromium.org/7129051/diff/11004/src/extensions/expe...
src/extensions/experimental/number-format.cc:326: const char* region =
icu_locale.getName();
wrapping up 'und_' + regionID in Locale class only to get back the raw
string seems a bit roo round-about. I'd just pass around 'region ID'
alone. OTOH, having to prepend 'und_' with char array is not fun...  So,
it's up to you.

Anyway, GetCurrencyCode() has to be revised to deal with '-u-cu-FOO'
case in icu_locale.

http://codereview.chromium.org/7129051/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »