HTML character reference display problems
I'm currently developing a site in Joomla, and one of the components I'm using makes use of a PHP file to administer the language. (english.php, spanish.php)
The problem I'm having is that if I use the plain text version of eg. "á
", it will show up in the browser tab title ok, but as a �
in the body of the page. But if I use a character reference (开发者_C百科5;
), the reverse happens!
Any ideas?
Thanks
bren
Couple of things:
Use
htmlentities
function for your text$my_text = htmlentities($string, ENT_QUOTES, 'UTF-8');
More info about the htmlentities function.
Use proper document type, this did the trick for me.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Use utf-8 encoding type in your page:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
精彩评论