Hi,
I just stumbled on some problem regarding Umlaut characters in included/header files.
Scenario:
I am using a common.h header file to define a function to translate the month names into German.
The relevant portion of the common.h:
std::string generateDateMonth(esphome::time::ESPTime time) {
std::string months[12] = {"Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"};
std::string month = months[atoi(time.strftime("%m").c_str()) - 1];
return month;
}
As the eagle-eyed my have noticed, the month of “März” has an umlaut character ä in it.
Then within the main yaml for the ESPHome display, I do call the function as follows:
display:
- platform: lilygo_t5_47_display
lambda: |-
auto time = id(ntp).now();
std::string dateFormat = generateDateMonth(time);
it.strftime(x, y+110, id(font_small), TextAlign::TOP_CENTER, dateFormat.c_str(), time);
I obviously included the umlaut ä in the glyphs statement of the font (and the ä will indeed render correctly on other instances of the same font).
font:
- file:
type: gfonts
family: 'Open Sans'
weight: bold
id: font_small
size: 40
glyphs:
'&@!,.?"%()+-_:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyzåÄäÖöÜü|/ß'
But on the Display this looks somethings like this:
M|rz
and the logger complains that:
Encountered character without representation in font: '\xe4'
So how can I carry over the umlaut from the common.h into the lambda function?
Thanks,
Thomas