Closed Bug 544414 Opened 15 years ago Closed 14 years ago

Use locale info when converting numbers to string in JS on Android

Categories

(Core :: JavaScript Engine, defect)

All
Android
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
fennec 2.0b4+ ---

People

(Reporter: mwu, Assigned: alexp)

References

Details

Attachments

(1 file)

Android doesn't have a useful localeconv so Number.prototype.toLocaleString can't be handled correctly. Need some kind of workaround.
tracking-fennec: --- → 2.0+
tracking-fennec: 2.0+ → 2.0b3+
Assignee: general → blassey.bugs
tracking-fennec: 2.0b3+ → 2.0b4+
Assignee: blassey.bugs → alexp
As a possible solution we could add some environment variables, like LOCALE_DECIMAL_POINT, LOCALE_THOUSANDS_SEP, LOCALE_GROUPING, and check them here: http://mxr.mozilla.org/mozilla-central/source/js/src/jsnum.cpp#1010 I've been also thinking about having some kind of a shunt like we had for WinCE. But this would make sense only if there are some other things, which could be implemented there. Any other suggestions?
Attached patch FixSplinter Review
Proposed fix using environment variables.
Blocks: 616377
Changed description to be more specific for this one as there is another meta bug 616377.
Summary: Handle locales correctly on Android → Use locale info when converting numbers to string in JS on Android
Comment on attachment 493477 [details] [diff] [review] Fix After further investigation of related bugs this fix looks like a sensible approach. Let's review it. Someone from JS team will need to have a look at this as well.
Attachment #493477 - Flags: review?(blassey.bugs)
Comment on attachment 493477 [details] [diff] [review] Fix > #ifndef HAVE_LOCALECONV >- rt->thousandsSeparator = JS_strdup(cx, "'"); >- rt->decimalSeparator = JS_strdup(cx, "."); >- rt->numGrouping = JS_strdup(cx, "\3\0"); >+ const char* thousands_sep = getenv("LOCALE_THOUSANDS_SEP"); >+ const char* decimal_point = getenv("LOCALE_DECIMAL_POINT"); >+ const char* grouping = getenv("LOCALE_GROUPING"); >+ >+ rt->thousandsSeparator = >+ JS_strdup(cx, thousands_sep ? thousands_sep : "'"); >+ rt->decimalSeparator = >+ JS_strdup(cx, decimal_point ? decimal_point : "."); >+ rt->numGrouping = >+ JS_strdup(cx, grouping ? grouping : "\3\0"); we might only want to do this for android (i.e. #ifdef ANDROID), but someone from the js team should make that call
Attachment #493477 - Flags: review?(sayrer)
Attachment #493477 - Flags: review?(blassey.bugs)
Attachment #493477 - Flags: review+
Attachment #493477 - Flags: review?(sayrer) → review+
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: