Need help me with с++ in lambda

Hello.
How to replace special character &nbsp?
I get sensor from Home Assistant, but sometimes there is &nbsp.
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

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.

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);