Acknowledged

String.toCharArray() crashes if the string contains Swedish characters

A user reported a crash in my data field, and I eventually narrowed it down to a line of code that was calling toCharArray() on a user-provided string.  In this case, the string was "Östra Hällsjön".

A single umlauted character is enough to cause toCharArray() to crash.  For example:

var testStr = "Ö";
var chars   = testStr.toCharArray();

In the simulator, the debug console shows:

Error: System Error
Details: Failed invoking <symbol>
Stack: 
  - compute() at C:\dev
{filename}.mc:178 0x10000d9c 

The line number is the line with the call to toCharArray().  I have not done extensive testing to see what other characters may cause it to crash.

SDK:  6.2.2

Devices:  Epix2 51mm, Fenix 6X, Edge 1000

Parents
  • Okay.  As far as the simulator goes, if I hardcode the (Swedish) string, it works fine.  My data field is displaying the value of Activity.Info.nameOfNextPoint, which I set via the Simulation -> Set Navigation Data menu option.  When I display the same string, but grabbed from "nameOfNextPoint", the Swedish characters are not displayed properly - they show a diamond with a "?" inside.  The string displays fine on an actual device, though.  (When it is getting that value from a course that the user loads.)

    I also created a SimpleDataField to check the call to toCharArray() against a hardcoded string, and it did not crash.  It still crashes in my data field, so I have no idea why the crash is ocurring - but that call is definitely the culprit.  Removing the swedish characters from the string eliminates the crash.  I will continue to try to create a simplified project that can recreate the problem.

Comment
  • Okay.  As far as the simulator goes, if I hardcode the (Swedish) string, it works fine.  My data field is displaying the value of Activity.Info.nameOfNextPoint, which I set via the Simulation -> Set Navigation Data menu option.  When I display the same string, but grabbed from "nameOfNextPoint", the Swedish characters are not displayed properly - they show a diamond with a "?" inside.  The string displays fine on an actual device, though.  (When it is getting that value from a course that the user loads.)

    I also created a SimpleDataField to check the call to toCharArray() against a hardcoded string, and it did not crash.  It still crashes in my data field, so I have no idea why the crash is ocurring - but that call is definitely the culprit.  Removing the swedish characters from the string eliminates the crash.  I will continue to try to create a simplified project that can recreate the problem.

Children
No Data