Cyrillic and hebrew language on Touch gfx for STm32 microcontrollers

156 views Asked by At

Hi I am working in an embedded application for microcontrollers for showing data on a display. The microcontroller is STM32 and the graphic tool I am using is called touch gfx. I want to show some texts in cyrillic and hebrew language. When i write the text in the gui of touch gfx i correctly see the text on the display

enter image description here

But when i try to run the following code for passing some text from code stm32cubeide

I got some question marks shown on the display ..

This is the code that is causing the problem for the russian and hebrew text

textArea4.setColor(touchgfx::Color::getColorFrom24BitRGB(236, 209, 18));//extra time?
            Unicode::strncpy(textArea4Buffer, parArea4[tipolingua][5], Unicode::strlen(parArea4[tipolingua][5])+1);
            textArea4.invalidate();

const char* parArea4[5][6] = { { "Preheating", "Ready", " ", "Baking", "Extra time", "Extra time?" }, { "Preriscaldo", "Pronto", " ", "Cottura", "Extra time", "Extra time?" }, { "Prechauffage", "Pret", " ", "Cuisson", "Extra time", "Extra time?" }, { "Предварительный нагрев", "Готовый", " ", "Выпечка", "дополнительное время", "дополнительное время?" }, { "חימום מוקדם", "מוּכָן", " ", "אֲפִיָה", "זמן נוסף", "זמן נוסף" } };

Any idea about how to fix it ?

Thanks a lot

1

There are 1 answers

0
Howell On

for example: 'П' UTF-8 '0xD0 0x9F', When you use char[], the first method is used by default.

  1. strncpy(UnicodeChar *RESTRICT dst, const char *RESTRICT src, uint16_t maxchars)
  2. strncpy(UnicodeChar *RESTRICT dst, const UnicodeChar *RESTRICT src, uint16_t maxchars)

For Touchgfx, 0xD0 and 0x9F are two unknown characters, so '?'

There's probably a better way, but this works

wchar_t text[] = L"ПППП";
Unicode::strncpy(textArea1Buffer, (Unicode::UnicodeChar *)text, TEXTAREA1_SIZE);
textArea1.invalidate();