Stupid bug with Kirbytext

I have a very stupid problem with kirbytext. The user had to write some credits in a kirbytext field.
But this name is called ‘&nbsp’ (this is the pseudo name). Kirbytext interpret this as a space but it’s not.
It doesn’t work also if I write for example & amp; nbsp

And I can’t use ->text() because I need some italic and bold inside the field.

Do you have some advices ?

Hm, &nbsp works for me? Alternative maybe &nbsp?

Oups I forget that my code looks like this
data-attribute="<?php echo $image->caption()->kirbytext() ?>
And I echo it with a little JS like

var caption = $(flkty.selectedElement).attr('data-attribute');
                $caption.html( caption );    

With jquery, I can’t use .text() because the data-attribute won’t return the bold/italic. So I’m a bit stuck and this is quite off-topic…