How can i decode my html entities chars (ÆØÅ)?
$test = "selvf&开发者_如何学Coslash;lgelig";
$test = html_entity_decode($test);
I want this to output "selvfølgelig", but this turns out as selvf�lgelig
How can i make this output like i want?
header("Content-Type: text/html; charset=UTF-8");
$string="selvfølgelig";
echo html_entity_decode($string, ENT_QUOTES, 'UTF-8')
i think you dont need to actually use this function. EDIT: you can use the < meta > tag that Qualcuno provided instead of throwing a header.
It's an encoding issue, not related to html_entity_decode.
Make sure your page is in UTF-8: put this tag in your <head></head>
section of the page.
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
Set, then, the third parameter of html_entity_decode(), charset
, to 'UTF-8'
(the default value).
PS: Please note that setting the encoding of the page to UTF-8 will solve many issues, but may introduce others, since UTF-8 can use multibyte characters. There may be security issues too, if you fail to validate input data correctly.
html_entity_decode($test, ENT_COMPAT, 'UTF-8');
There are other charsets too:
html_entity_decode($test, ENT_COMPAT, 'ISO-8859-15');
You need to define with which charset you're working with.
You will have to use the third parameter of html_entity_decode to specify a character set.
$test = html_entity_decode($test, ENT_COMPAT, 'utf-8');
精彩评论