Apache Cordova
  1. Apache Cordova
  2. CB-141

Syntax Error raised in phonegap-1.3.0.js in FR-FR locale when watching the accelerometer


    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.0
    • Fix Version/s: 2.0.0
    • Component/s: WP7 (defunct)
    • Labels:
    • Environment:

      All phone configured to use the FR-FR locale (the emulator included)


      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) :



      " instead of "


      " 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\":






      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.


        David Rousset created issue -
        Jesse MacFadyen made changes -
        Field Original Value New Value
        Status Open [ 1 ] In Progress [ 3 ]
        Jesse MacFadyen added a comment -

        commit: 440d430e2fcbfa4288fa12b19de7a146e16b0d8e

        Jesse MacFadyen added a comment - commit: 440d430e2fcbfa4288fa12b19de7a146e16b0d8e
        Jesse MacFadyen made changes -
        Resolution Fixed [ 1 ]
        Status In Progress [ 3 ] Resolved [ 5 ]
        Fix Version/s 2.0.0 [ 12318875 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open In Progress In Progress
        2h 12m 1 Jesse MacFadyen 20/Dec/11 18:43
        In Progress In Progress Resolved Resolved
        14m 22s 1 Jesse MacFadyen 20/Dec/11 18:57


          • Assignee:
            Jesse MacFadyen
            David Rousset
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: