I have the standard XAMPP installation on win7 (x64). Having had my share of encoding troubles in a past project where mysql encoding did not match with the php enconding wh
When [dropping] the encoding settings mentioned above all characters [are rendered] correctly but the encoding that is detected shows either windows-1252 or ISO-8859-1 depending on the browser.
Then that's what you're really sending. None of the encoding settings in your bullet list will actually modify your output in any way; all they do is tell the browser what encoding to assume when interpreting what you send. That's why you're getting those �s - you're telling the browser that what you're sending is UTF-8, but it's really ISO-8859-1.
Check if any of your .php
files which printing some text, also is correctly encoding in utf-8
.
Tell PDO your charset
initially.... something like
PDO("mysql:host=$host;dbname=$DB_name;charset=utf8;", $username, $password);
Notice the: charset=utf8;
part.
hope it helps!
I'm from Brazil and I create my data bases using latin1_spanish_ci
. For the html and everything else I use:
charset=ISO-8859-1
The data goes right with é
,ã
and ç
... Sometimes I have to put the texts of the html using the code of it, such as:
Olá
gives me
Olá
You can find the codes in this page: http://www.ascii.cl/htmlcodes.htm
Hope this helps. I remember it was REALLY annoying.
The problem is the charset that is being used by apache to serve the pages. I work with Linux, so I don't know anything about XAMPP. I had the same problem too, what I did to solve the problem was to add the charset to the charset
config file (It is commented by default).
In my case I have it in /etc/apache2/conf.d/charset
but, since you're using Windows the location is different. So I'm giving you this like an idea of how to solve it.
At the end, my charset config file is like this:
# Read the documentation before enabling AddDefaultCharset.
# In general, it is only a good idea if you know that all your files
# have this encoding. It will override any encoding given in the files
# in meta http-equiv or xml encoding tags.
AddDefaultCharset UTF-8
I hope it helps.
Looks like nobody mentioned
SET NAMES utf8;
I found this solution here and it helped me. How to apply it:
To be all UTF-8, issue the following statement just after you’ve made the connection to the database server: SET NAMES utf8;
Maybe this will help someone.