Hello, I have a php script that generates a list of all cities from my country. The problem is that some romanian specific characters are not displayed( they are replaced by "?" signs). Page's meta information is that <!DOCTYPE html> <html> <head> <title>Page Title</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body> List </body> </html> I have tried in two browsers. I am editing the file in cPanel's code editor, but I also downloaded the file, saved it on my computer with UTF-8 encoding and uploaded it again. Thanks. UPDATE: if I write those characters in the page, they are displayed ok, so the problem is that when php selects those records from database, doesn't recognisez those characters SOLVED: mysqli_set_charset($db_conn,"utf8") - before the query to the DB
Make sure your database is set up to save as utf-8. gary //edit: I stopped reading too soon. :shrug: It is good that you fixed it. ~gt
Also if you're going to go ahead and use a HTML 5 doctype, you might as well use the HTML 5 charset declaration instead of the outdated http-equiv: <meta charset="utf-8"> Is WAY simpler. NOT that it really matters on deployment since your ACTUAL http headers should be setting that, and if it's setting anything else, the one in the markup is ignored anyways. "real world" the only time that charset declaration should do anything is if you are serving it as a local file instead of via a web server. Just an observation; something to keep in mind.
Sorry for the late answer. I read that HTML5 uses utf-8 by default so '<meta charset="utf-8">' is not needed( theoretically ). What do you think about that ?
Considering SERVERS by default send iso-8859-1 and that HTTP headers by definition override the any http-equiv or charset declarations, the charset meta is meaningless when deployed from a real server anyways unless you disable what the server sends in the response headers. (PHP's header command for example, or via htaccess). The only real reason to have a charset declaration is as a fallback during local testing on static code, or should the server fail to send headers properly. Once you are sending it from a real server software like iiS, ngnix or Apache, 99% of what people try to set from http-equiv doesn't matter one way or the other. Which is why that declaration, or the old http-equiv can be completely meaningless if the server is still saying the default!
Even if I have solved the problem and theoretically my answer is the best I will give you "the best answer" because it will be very useful for those who will read the post. Thank you, again !