Forum General


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

xamarin non-english dot and comma calculations (Xamarin multi-language support)

brendonshawbrendonshaw Member ✭✭

We are developing a mobile application using Xamarin cross platform development for Android and iOS, which is reading data from a Bluetooth device that transfers data as a float i.e. 12.22 and it will support multiple languages.

When it's set to English all our calculations are fine, but when set to non-english the calculations go completely wrong. I know what is wrong in non-english languages it's treating the "." as an "," which is means a 12.22 becomes 12,22. Therefore, screwing up our calculations.

I have found similar problems, but they force the complete language to English which means we lose the translations and other fixes look very complex for what must be a simple fix.

Is there a easy fix to this problem, like setting a flag in the Xamarin multi-language support

Update : With the BLE transfer code, we can see the string but when it convert it we get 6000000 for French or 60 for English.

  private async Task<double> 
  GetDatastoreValue(Plugin.BLE.Abstractions.Contracts.IService service, string param)
        var datastore_param_char = await service.GetCharacteristicAsync(Guid.Parse(datastore_param_uid));
        var datastore_param_val = await service.GetCharacteristicAsync(Guid.Parse(datastore_value_uid));

        await datastore_param_char.WriteAsync(Encoding.ASCII.GetBytes(param));
        byte[] result = await datastore_param_val.ReadAsync();

         string rslt = Encoding.ASCII.GetString(result);
          Debug.WriteLine("GetDatastoreValue -> result " + result);
          double val = Convert.ToDouble(rslt);
          Debug.WriteLine("GetDatastoreValue -> val -> "+ val);
          return val;
        return 0.0;


Sign In or Register to comment.