php - XML charactor encoding issues with accents -
i have had problem few times while working on projects , know if there's elegant solution.
problem pulling tweets via xml twitter , uploading them db when output them screen these characters:
"moved dusseldorf.รข��" or tambiã©n
and if have russian characters lots of ugly boxes in place.
what correct native accents show under 1 encoding. thought possible utf-8.
what using
- php, mysql
after reading in xml file doing following cleanse data:
$data = trim($data); $data = htmlentities($data); $data = mysql_real_escape_string($data); my database collation is: utf8_general_ci
web page character set is: charset=utf-8
i think have html entities appreciate solution works across board on projects.
thanks in advance.
replace line:
$data = htmlentities($data); with this:
$data = htmlentities($data, null, "utf-8"); that way, htmlentities() leave valid utf-8 characters alone. more information see the documentation htmlentities().
Comments
Post a Comment