|
|
Question : Special characters display incorrectly when pulling from Wordpress database.
|
|
I am developing a website which uses Wordpress as its blog component. When writing a post with special characters (— for example), the special characters render correctly on the wordpress portion of the site. However, when I pull data from the Wordpress database to display on the homepage (which is independent of the Wordpress framework), the special characters display in a peculiar manner (diamond with ? in center). It appears that the character is not being encoded correctly.
I checked the encoding when in the wordpress section of the site, and both browser and the header of the page are using UTF-8. The same is true for the homepage of the site. I can actually get the special characters to display correctly on the homepage if I switch the browser encoding to ISO-8859-1.
How do I correct this problem? I have tried using htmlentities() and htmlspecialchars() on homepage, but this doesn't correct the problem.
|
Answer : Special characters display incorrectly when pulling from Wordpress database.
|
|
PLEASE TRY THIS,
echo utf8_decode($str);
?>
surely this will help you...
utf8_decode()
Converts a string with ISO-8859-1 characters encoded with UTF-8 to single-byte ISO-8859-1
|
|
|
|
|