Alyce
(Альберт Маманов)
1
Hello.
How to replace special character  ?
I get sensor from Home Assistant, but sometimes there is  .
I want to replace it with " " (space)
- platform: homeassistant
entity_id: sensor.precipitation
id: fc_precip
internal: true
it.printf(10, 10, id(font_name), TextAlign::BASELINE_LEFT, "%-30s", id(fc_precip).state.c_str());
Thanks
zoogara
(Daryl)
2
You’ll probably need to write some code to do the substitution.
There are plenty of C++ reference sites with substring substitution examples. None of them look straightforward but they should work.
You won’t be able to achieve it with just a printf statement.
Alyce
(Альберт Маманов)
3
I try this but it did not work for me - cyclic reboot.
using namespace std;
string precip=id(fc_precip).state.c_str();
string nbsp = "\xc2\xa0";
precip = precip.replace(precip.find(nbsp), nbsp.length(), " ");
it.printf(x1n, y1, id(font_name), TextAlign::BASELINE_LEFT, "%-30s", precip);