Property value with a long string 40 characters cannot be saved

Hi,

I have a property style, which is encoded from users' configuaration.

With this, users can recover their pervious configurations or reproduce awesome ones from strings shared by others.

But I found a weird problem, the modification cannot be saved as expected.

The length of the string is 40 like MJHxx11x24197g0vczAw5436xx90000x00YD3NLS.

AFAIK, if the memory reachs the limit, the callback onSettingsChanged won't be invoked after properties changed. But my wf has more than 10kB available after start.

Other boolean property works as usual.

Perhaps the change dictionary is too large to send to my WF,ie. over the size threshold. After all, a string with 40 characters means 80 Bytes,in which case the dictionary will be 80 Bytes at least.

Do you have any idea to deal with this?

Top Replies

All Replies

  • Yes. It looks like the long string is the last straw. If I compress the string, all recovers.  LOL

  • Perhaps the change dictionary is too large to send to my WF,ie. over the size threshold. After all, a string with 40 characters means 80 Bytes,in which case the dictionary will be 80 Bytes at least.

    Nitpick, not if the encoding is UTF-8. Then each character is 1 to 4 bytes (and ASCII chars are guaranteed to be 1 byte each.)

    e.g.

    var str = "0123456789012345678901234567890123456789"; // 40 chars / 49 bytes

    var str2 = "GrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinningGrinning";  // 40 chars / 169 bytes

  • Aha, in java, you are right. But in monkeyC, I consulted the document and it said all chars are stored as unicode.

  • Aha, in java, you are right. But in monkeyC, I consulted the document and it said all chars are stored as unicode.

    My tests in the previous post are based in Monkey C, although of course they may be influenced by the fact that my Monkey C file itself is encoded in UTF-8.

    However, I did a test in the simulator with string app settings and found similar results, which matches my memory of how it's always worked.

    Here's a settings dictionary value that's a 40 character string (ASCII only) -- the size is 50 bytes.

    I know that especially in a Windows context, when people say "Unicode", they mean UTF-16, but in this case, just because Garmin says that a String consists of Unicode characters, doesn't mean that it necessarily uses UTF-16.

    https://stackoverflow.com/a/643713

    Maybe this is one of those things that could be clarified in the documentation.

  • I think that there are 2 things here:
    1. the documentation differentiates between byte and char, and that makes sense, if you see things like:

    <settingConfig type="alphaNumeric" maxLength="32"/>
    you want to know if it's 32 bytes (32 English chars or 16 Hebrew chars or probably 8 Chinese chars)
    or if it's 32 chars (but then it can use 32 bytes for English, and up to 128 bytes for Chinese)

    So in every context it has to be clear if it's counted in chars or bytes.


    2. The OTHER thing is what does "unicode" mean where that is used in the docs. UTF-8? UTF-16? UTF-32? Maybe something else?
  • The OTHER thing is what does "unicode" mean where that is used in the docs. UTF-8? UTF-16? UTF-32? Maybe something else?

    LOL. Not clarified

  • I know that especially in a Windows context, when people say "Unicode", they mean UTF-16, but in this case, just because Garmin says that a String consists of Unicode characters, doesn't mean that it necessarily uses UTF-16.

    You are really right. 

    Several hours ago, I found if I input Chinese (UTF-16) characters into a property inputbox and then tried to display it on a APAC device it only displayed some boxs. So the string indeed is stored as ASCII only. LOL

  • Several hours ago, I found if I input Chinese (UTF-16) characters into a property inputbox and then tried to display it on a APAC device it only displayed some boxs. So the string indeed is stored as ASCII only. LOL

    I don't think that means the string is stored as ASCII only. It could just mean that the device doesn't have those characters in its fonts.

    IIRC, even APAC devices support some basic unicode characters, like common emoji.

    I was def able to use Unicode box drawing characters in app settings. (Although that's displayed on a phone, so doesn't prove anything either way.)

  • So in every context it has to be clear if it's counted in chars or bytes.

    I agree. My only point is I don't think UTF-16 is the encoding.

    2. The OTHER thing is what does "unicode" mean where that is used in the docs. UTF-8? UTF-16? UTF-32? Maybe something else?

    I think they mean that Unicode characters are supported in general, without specifying what the specific encoding is.

    This kind of thing is a common IT/Computer Science problem where certain words have more than one meaning depending on context, especially due to historical usage (i.e. which usage came first or was the most common.)

    For example, "garbage collection" can mean a certain kind of garbage collection (i.e. not reference counting but tracing garbage collection), or it can mean garbage collection algorithms in general (which could be said to include reference counting).

  • Really confusing. I can display Chinese in the property at ciq app settings, But if I retrive the string and draw it on the screen, only boxs will show up