Description
I have written a function that has a parameter
char*
and adds the string to a text area object. It’s working just fine except when I try to print charcaters like “ä”, “ö”, “ü” or “ß”. These characters just seem to be ignored and do not appear on the display.
What MCU/Processor/Board and compiler are you using?
I am using the i.MX RT1060 EVK.
What LVGL version are you using?
v7.0.0
What do you want to achieve?
I want to print umlauts to a text area using the function
lv_textarea_add_text(obj, str)
What have you tried so far?
- I made sure the text area accepts the characters “ä”, “ö”, “ü” and “ß”.
- I made sure any string I passed to my function was zero-terminated
Code to reproduce
/* How the text area is created and initialized */
void TGUI_initSimpleTerminal(void)
{
pObjTa = lv_textarea_create(lv_scr_act(), NULL);
lv_obj_set_size(pObjTa, LV_HOR_RES, LV_VER_RES / 2);
lv_obj_set_style_local_bg_color(pObjTa, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT,
LV_COLOR_BLACK);
lv_textarea_set_text(pObjTa, "");
const char * accepted = "abcdefghijklmnopqrstuvwxyzäöüßABCDEFGHIJKLMNOPQRST"
"UVWXYZÄÖÜ,.!1234567890\"§$%&/()=?*+-#'°><|_ ";
lv_textarea_set_accepted_chars(pObjTa, accepted);
/* A test output right after initialization */
lv_textarea_set_text(pObjTa, "Hällö\0");
}
/* My function */
/**
* Print a text to the terminal's text area
* @param text
*/
void TGUI_printToSimpleTerminal(const char * aStr)
{
if(strcmp(aStr, BACKSPACE) == 0)
{
lv_textarea_del_char(pObjTa);
}
else
{
lv_textarea_add_text(pObjTa, aStr);
}
}
/* lv_conf.h */
#define LV_TXT_ENC LV_TXT_UTF8
Output
What I wanted / expected:
Hällo
What I see:
"Hll"