Skip to main content
HTD
Senior II
June 10, 2022
Solved

How to display UTF-8 text in a TextArea Wildcard in TouchGFX?

  • June 10, 2022
  • 1 reply
  • 1789 views

I set the character wildcards properly, to include all required characters.

Here's my example code:

Unicode::strncpy(errorTextBuffer, "Zażółć gęślą jaźń.", ERRORTEXT_SIZE);
errorText.resizeToCurrentText();
errorText.invalidate();

But what I get is this:

0693W00000NrbceQAB.pngThe character encoding for my entire project is "UTF-8", so this is the file encoding.

I tried to use UART as the debug console and it outputs the UTF-8 text with no problems.

I guess Unicode functions of TouchGFX don't expect the char* strings to be UTF-8. How it is done properly?

This topic has been closed for replies.
Best answer by HTD

Oh, silly me:

Unicode::fromUTF8((const uint8_t*)"Zażółć gęślą jaźń", errorTextBuffer, ERRORTEXT_SIZE);
errorText.resizeToCurrentText();
errorText.invalidate();

1 reply

HTD
HTDAuthorBest answer
Senior II
June 10, 2022

Oh, silly me:

Unicode::fromUTF8((const uint8_t*)"Zażółć gęślą jaźń", errorTextBuffer, ERRORTEXT_SIZE);
errorText.resizeToCurrentText();
errorText.invalidate();