php - UTF8 real decode -
possibly simple question , wondering how can decode utf8 characters readable characters.
for example :
l'heure suprême
into
l'heure suprême
i tried following :
utf8_encode , utf8_decode , `html_entity_decode($string, ent_compat, "utf-8");`
the output never gave me correct characters , example
html_entity_decode($string, ent_compat, "utf-8"); returned l'heure suprême
edit : stupid question , html_entity_decode($string, ent_compat, "iso-8859-15");
did trick
in order results displayed, you'll need tell receiving end, encoding used:
header('content-type: text/plain; charset=utf-8'); $string = 'l'heure suprême'; print html_entity_decode($string, ent_compat, "utf-8");
the output without explicitly naming charset encoding provokes undefined behavior. earlier today, suggested a great article joel spolsky on unicode , character sets. makes read , i'll suggest "skim over" it.
Comments
Post a Comment