Displaying extended characters

How do people go about displaying extended characters from within monkey C?

If you simply embed extended characters in text within quotes in the source, unless you are lucky and the character set happens to match that on the watch, what you get on the watch will be wrong. From what I can see there are two possible ways.

1) Encode your characters as a utf8 array and then use StringUtil.utf8ArrayToString() to display.

2) Work out the numeric value of the character in the font you are using and then use toChar() to convert it to a character.

The UX Guide shows you what characters are available in each font without giving a character set, and gives no easy way of translating individual characters into something you can use in your code. The only way I have found is to write a small loop to go through each character in turn to find the one you want.

And then if you use System.println() to output strings with extended characters, it seems to show the correct extended character, but prefixes it with a capital A with an accent. I assume this is a bug?

The programmers guide does not give any hints on how to use extended characters. How should we be programming with extended characters to ensure the correct characters are displayed?
  • with your interest in BG weather, can I guess you're thinking a degree symbol?
    UFT-8 for at least the source file were it's defined. I used an editor (I can't recall which one any more) where I could edit the file and use a key sequence to enter the hex value. Since then, I'll just copy this line into new projects. You may be able to just copy it into your own code from the forum:

    var degree="°"; //utf-8, b0 hex, 176 dec


    As a note, the degree symbol isn't supported in all fonts or on all devices, but the sim will show you that, often with a box where the degree symbol should be.
  • I recommend to save all .mc source files and resource files in UTF-8 codepage. There is a setting in Eclipse to do so.
    Moreover, I'd say UTF-8 is must-have in your project. All fonts embedded support many international characters. I assume APAC models have more advanced character set for their complex characters.

    I tried so with Cyrillic characters and any specific like in letter e in word fēnix. Now it's ok (very old fenix 3 firmwares however had some issues with that, fixed).
  • Yes, it was needing to print a degrees symbol which got me thinking about this, but I was more interested in the general case than one particular character. I am currently using utf8ArrayToString() to get this working since embedding a paste from a web page had not worked. I did also find that toChar() of the relevant value also worked but was wondering what people did in general if they were wanting to use lots of extended characters. Just typing them in is the easiest approach as long as Eclipse is setup to use the same codepage as the watch fonts use.

    Clearly I have eclipse setup with the wrong codepage or hit some other issue. I'll have to look into how I have it setup so I can just type.
  • The "character" type was introduced quite some time after I started doing CIQ, so really don't use it (I'm sometimes stuck in my ways! :) )

    Are you seeing it display weird with a Sys.println() but ok on the display in the sim? I guess I wouldn't worry too much about the Sys.println() if it's only there..
  • When I pasted the "°" into the text in the source it was being displayed on the watch and with println() incorrectly as a wrong character.

    When I changed to encoding it as a utf8 character in an array and I used utf8ArrayToString() it displays on the watch fine, but println() does not show it properly, it shows as "ð".

    I've noticed that all extended characters are displayed as a double character when using println(). I suspect this is a bug in println handling of double byte characters. But as you say, this does not really matter, what matters is that it is correct on the watch (and Sim), and it is. I should probably file a bug report though for completeness.
  • When I pasted the "°" into the text in the source it was being displayed on the watch and with println() incorrectly as a wrong character.

    This happens in device because you don't use UTF-8 codepage in Eclipse settings for project. Save .MC files in UTF-8 and on device you will see the same you type in source file. "Properties" - "Resource" tab and "Text file encoding" setting. All source files along with resource files must be in UTF-8 codepage. I'd recommend to put it at the header of the documentation.

    but println() does not show it properly, it shows as "ð".

    I confirm this bug, checked with Cyrillc charset. Information sent to CIQ Team.
    println console uses cp1252 codepage for multiple byte characters.
  • This happens in device because you don't use UTF-8 codepage in Eclipse settings for project. Save .MC files in UTF-8 and on device you will see the same you type in source file. "Properties" - "Resource" tab and "Text file encoding" setting. All source files along with resource files must be in UTF-8 codepage. I'd recommend to put it at the header of the documentation.
    And sure enough, after changing the source file encoding to utf-8 what I paste into the source matches what appears on the watch. Thanks for the tip.
  • The UX Guide shows you what characters are available in each font without giving a character set, and gives no easy way of translating individual characters into something you can use in your code.


    Yep, this has always really bugged me. Because of the way our fonts work, the tool we use to export the font sets will only export it to a graphic file format, which is not what I had originally wanted to do. It's an interim solution, just because it's what we have, but I'd really like to provide true character maps with more identifying information.

    I already have the bug report from a1234.garmin, so we'll look into this further.
  • Thanks Brandon. I have to say that most people probably do not often need to use extended characters very often, but those that do will surely have struggled with the current documentation.
  • Still the bug. CIQ 3.0.11, Eclipse 2019-03

    I.e. name from source .mc stored in UTF-8:

    fēnix® 5 Plus

    is displayed on the console window as:

    fД“nixВ® 5 Plus