I have the following code:
mb_convert_encoding($string, 'HTML-ENTITIES', 'utf-8');
I need to have alternative code that does the same, but does not use any mb_ * functions (the mb extension is not available in some environments).
I thought that
utf8_decode(htmlentities($string, ENT_COMPAT, 'utf-8'));
should do the same, but unfortunately does not.
string php character-encoding
Simon
source share