2

I just thought I'd share this because it took me a bit of time to figure out tonight.

When members post content with MS Word quotes, etc., and they look funky on our UTF-8 websites, it's because those characters need to be converted to UTF-8. This bit of code worked for me so I thought I'd share.

// Convert ISO-8559-1 characters (and MS Word characters) to UTF8
$string = iconv('UTF-8', 'ISO-8859-1//TRANSLIT', $string);

// Run htmlspecialchars accepting UTF-8 characters (on older versions of PHP)
return htmlspecialchars($var, ENT_COMPAT, 'UTF-8');
Votes + Comments
thanks!
2
Contributors
1
Reply
18
Views
2 Years
Discussion Span
Last Post by gabrielcastillo
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.