2025-11-19 2:46 AM
I'm having a hard time understanding when to use Unicode::snprintf vs Unicode::strncpy, also because I'm seeing different behavior when it comes to wildecards.
I have a font where I've set various wildcard characters (see below)
Now, I have a text area with a buffer of 10.
If I use
Unicode::snprintf(myTextBuffer, MYTEXTTEXT_SIZE, "%s", "myText");I'm seeing the text on the touchscreen as ???, so it basically falls back to the fallback characters.
Instead, if I use
Unicode::strncpy(myTextBuffer, "myText", MYTEXTTEXT_SIZE);I correctly see myText as the text
Why is that?
2025-11-19 7:28 AM
Hi @nico23
>>" I correctly see myText as the text"
That is because strncpy is overloaded and correct version is picked by compiler#
\include\touchgfx\Unicode.hp
However, Unicode::snprintf() expects Unicode string so add preffix 'u' e.g. u"unicode text char16_t"
Unicode::snprintf(myTextBuffer, MYTEXTTEXT_SIZE, "%s", u"myText");