Correct method to transform the text value into a utf8 string value

Correct method to transform the text value into a utf8 string value.

I have tested on my project and it is fine. Test you too please.