Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

special characters turn into question marks php html

I read all the topics found on stackoverflow and other forums, it's hosted on hostgator and I've never had problems with their servers before although quotes for example are transformed into question marks, normal ones not with black diamonds or anything. Here is what I've tried:

 header('Content-Type: text/html; charset=utf-8');

and

 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

This is what I use for doctype if that matters:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

I use Unitron for osx to write my code and I've checked that the files should include utf-8.

And the text that I am trying to display is just html, within a php page.

Anyone have any clue on how to help me?

like image 388
user1250526 Avatar asked Jun 20 '26 03:06

user1250526


2 Answers

Check that your file is encoded in UTF8, for instance with Notepad++ go to "Encoding" > "Convert in UTF8" and save the file.

like image 135
adrien Avatar answered Jun 22 '26 17:06

adrien


You should use htmlentities to convert any entities in your text to html entities; for example, the copyright sign will become © &copy;

like image 28
bigblind Avatar answered Jun 22 '26 16:06

bigblind