Grr, f***, sh**, a** f***! I am setting up one of my PHP CMS's and was having trouble with non-ASCII characters. After pulling my hair out and endless googling I found the problem, htmlentities(). It turns out that htmlentities() is set to ISO-8859-1 by default and needs a specific parameter to be UTF-8.
I found this:
/**
* Encodes HTML safely for UTF-8. Use instead of htmlentities.
*
* @param string $var
* @return string
*/
function html_encode($var)
{
return htmlentities($var, ENT_QUOTES, 'UTF-8') ;
}
Here:
http://developer.loftdigital.com/blog/php-utf-8-cheatsheet
No comments:
Post a Comment