incubator-callback-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Rousset (Created) (JIRA)" <>
Subject [jira] [Created] (CB-141) Syntax Error raised in phonegap-1.3.0.js in FR-FR locale when watching the accelerometer
Date Tue, 20 Dec 2011 16:30:30 GMT
Syntax Error raised in phonegap-1.3.0.js in FR-FR locale when watching the accelerometer

                 Key: CB-141
             Project: Apache Callback
          Issue Type: Bug
          Components: WP7
    Affects Versions: 1.3.0
         Environment: All phone configured to use the FR-FR locale (the emulator included)
            Reporter: David Rousset
            Assignee: Jesse MacFadyen

There is a bug in the Accelerometer.cs file of the WP7GalClassLib library in the way to formats
the current coordinates into JSON format. 

Here is the kind of output produced on a FR-FR locale (and on any locale using the coma character
as the separated character for numerics) :

"{\"x\":0,00472,\"y\":-0,19879,\"z\":-0,98115}" instead of "{\"x\":0.00472,\"y\":-0.19879,\"z\":-0.98115}"
for EN-US.

The JSON.Parse() instruction then raises a Syntax Error exception later on due to the bad
formatting of the JSON string. 

To fix the bug, the code of the GetCurrentAccelerationFormatted() method needs to be changed
by this one:

private string GetCurrentAccelerationFormatted()
    string resultCoordinates = String.Format("\"x\":{0},\"y\":{1},\"z\":{2}",
             accelerometer.CurrentValue.Acceleration.X.ToString("0.00000", CultureInfo.InvariantCulture),
             accelerometer.CurrentValue.Acceleration.Y.ToString("0.00000", CultureInfo.InvariantCulture),
             accelerometer.CurrentValue.Acceleration.Z.ToString("0.00000", CultureInfo.InvariantCulture));
    resultCoordinates = "{" + resultCoordinates + "}";
    return resultCoordinates;

It adds the usage of CultueInfo.InvariantCulture available in the System.Globalization namespace
to always have the same formatting whatever the locale is. 

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message