UTF-8 format for display º and %


I want to display a sensor data with following the characters ºC and % I have the UTF8 enabled in the lv_conf.h


And I can display the lv_label_set_text(label1, LV_SYMBOL_OK); like documentation says, but when I try to display the data with the ºC and % the º and % don’t appear, only appear the C. I use the
LV_FONT_MONTSERRAT_26 enabled in the lv_conf.h, how can I display the º and % simbols? Thanks in advance

What MCU/Processor/Board and compiler are you using?

ESP32 with ILI9341 display and Arduino IDE

What LVGL version are you using?


What do you want to achieve?

Display correctly the simbols º and %

Code to reproduce

    int co2 = airSensor.getCO2();
    float temp = airSensor.getTemperature();
    float hum = airSensor.getHumidity();

     char co2C[10];
     char tempC[10];
     char humC[10];

      sprintf(co2C, "%i ppm", co2);
       sprintf(tempC, "%.2f ºC", temp);
        sprintf(humC, "%.2f %", hum);


    lv_label_set_text(label_co2, co2C);
    lv_label_set_text(label_temp,  tempC);
    lv_label_set_text(label_hum,  humC );

Screenshot and/or video

In the serial monitor I can see ºC correctly but no %

In the display only I can see C

use double percentage like

printf("%.2f %%", hum);

and º if i’m not mistaken not supported

1 Like

It works to % thanks! and how can I display º?

I use “%0.2f°c”

Make sure that your C file is being saved in UTF-8 format. Sometimes the OS uses a different format, then the compiler outputs some other type of Unicode encoding and LVGL has no idea what to display.

Remember º is not always the same as ° there are about 2 or 3 symbols for degree…

no works for me, this only display c. Thanks!

And how can I make sure of that? Thanks!

Thats odd. The symbol is in the monterrat_26.c file. Line 1596. Can you try copying the symbol from there in case HTML is replacing it with something else?

Gabor was very kind to me, he added it in a while ago :slight_smile:

1 Like

if i understand correctly this symbol works for v7 !?

Yes, montserrat is the default in 7. Roboto in 6.

1 Like

ouuu, thanks, i`am loking later

Here is an example of it working:


It works the simbol of the monterrat_26.c file. Line 1596. it’s different than my keyboard symbol º. Thanks a lot!

Indeed. All degree symbols are not the same… :frowning:

thanks to you for your support

1 Like

good luck))

How do you select that background color? I divide my display in 3 parts, top, middle and bottom, my theme its LV_THEME_MATERIAL_FLAG_DARK but if I don’t select the color of the middle it is white, how can I setup your middle background color? Thanks a lot

bg_middle = lv_obj_create(scr, NULL);
    lv_obj_clean_style_list(bg_middle, LV_OBJ_PART_MAIN);
    lv_obj_set_style_local_bg_opa(bg_middle, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT,LV_OPA_COVER);
    lv_obj_set_style_local_bg_color(bg_middle, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
    lv_obj_set_pos(bg_middle, 0, 50);
    lv_obj_set_size(bg_middle, LV_HOR_RES, 240);

you can also use below for degree symbol.

printf("%.2f %cC", hum, 0xB0 );
1 Like