Magento – Magento2, custom widget save data wrong encoding

character encodingmagento2widgets

I create a custom widget for magento2. I have one text parameter:

<parameter name="title" xsi:type="text"  visible="true" sort_order="1" >
            <label translate="true">Title</label>
        </parameter>

When I save data, if I use characters like à, or ã, or ü por example, the are saved with wrong encoding. For example ü became ü.
This only happens on my widget. All the rest is saving with right encoding.

How can I set right encoding for a widget or a parameter?

thank you

Best Answer

Apparently, I have no direct answer to your question as it seems to be an issue with Magento (see Issue #5132 of Magento2 on GitHub).

Workaround

Just utf8_decode your variables before echoing them. For example:

$text_w_correct_umlauts = utf8_decode($this->getData('text_w_incorrect_umlauts'));