Closed
Bug 441370
Opened 17 years ago
Closed 8 years ago
Date.toLocaleString() uses wrong encoding if called from an XPCOM component
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: jwkbugzilla, Unassigned)
Details
Steps to reproduce:
1. Go to Regional and Language Options in the Control Panel, select Russian locale.
2. Start Firefox
3. Type |javascript:alert(new Date().toLocaleString())| in the location bar - note that this gives you something like "23 Июнь 2008".
4. Now add |throw new Date().toLocaleString())| to the source code of some XPCOM component and restart Firefox - this gives you something like "23 Èþíü 2008" (Windows-1251 => ASCII => Unicode encoding) in the error console.
Same issue affects non-XPCOM JavaScript if it has been called from XPCOM as callback though reproducing is more difficult here. I had to add setTimeout(..., 0) to work around.
Looking at date_toLocaleHelper in jsdate.c, seems like localeCallbacks aren't set on the JS context.
Comment 1•16 years ago
|
||
I think this could be the same issue...
I faced with the problem when scripts* for Greasemonkey (addon, which allows running user scripts) use Date.toLocaleString() function.
(*) scripts which not call this function from a callback.
It appears that Date.toLocaleString() function returns result as CP1251 (my system locale settings) instead of using the encoding defined on current page (UTF-8 in my case).
Example: Ikariam Empire Board script
http://userscripts.org/scripts/show/41051
Bug report:
http://userscripts.org/topics/40577
Comment 2•15 years ago
|
||
Dupping forward to newer bug about this same issue which is already a blocker.
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → DUPLICATE
Still reproducible on Nightly 2011-04-23 (Windows Vista, ja), using Sandbox.
Error Console gives:
Cu.evalInSandbox('new Date().toLocaleString()', new Cu.Sandbox(this))
//=> 2011”N4OEZ(24“u' 17:53:16
new Date().toLocaleString()
//=> 2011年4月24日 17:53:25
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
Comment 4•14 years ago
|
||
Still present on latest Fx 5.0
Try
alert((new Date()).toLocaleString())
on Web Console gives wrong encoding,while
javascript:alert((new Date()).toLocaleString())
gives the correct one.
| Assignee | ||
Updated•11 years ago
|
Assignee: general → nobody
Comment 5•8 years ago
|
||
We're now using ICU for toLocaleString() (bug 853301), so this bug should no longer be reproducible. Marking as WFM.
Status: REOPENED → RESOLVED
Closed: 15 years ago → 8 years ago
Resolution: --- → WORKSFORME
You need to log in
before you can comment on or make changes to this bug.
Description
•