Page 1 of 1

MySQL Encoding

Posted: Wed Mar 24, 2010 6:35 am
by shiznatix
Hey-ho

Ok so I am having a problem with encoding. I have this site thats all Estonian. I am outputting text from the DB and from just the echo "Estonian chars". The problem is that echo "Estonian chars" works the trick but anything I pull from the DB that is not standard English latin chars is screwed up.

So I think to myself, "Set the encoding on the DB and with a header()"! Well, that doesn't work. I set the char set to the DB and to all the tables and to each TEXT or VARCHAR field to "utf8_estonian_ci" and did a header('Content-Type: text/html; charset=utf-8'); but still no dice.

The extra characters most used are "üõäö".

Example of what happens:

Code: Select all

 
<?php
 
echo "õüäöäöäöüüüüüü";
 
echo getQuestionWithCrazyCharsFromDb();
 
if I don't set header(utf-8) there then the first echo is going to be all messed up but the from db one will work the trick. If I do have the header(utf-8) then its the reverse. So one of these is not in UTF-8 but I can't figure out how thats possible when the DB and the tables and the fields all have utf8_estonian_ci encoding set to them. How do I just get this set to the proper utf-8 situation and move on with my life?

Re: MySQL Encoding

Posted: Fri Mar 26, 2010 6:29 am
by shiznatix
Edit: figured it out. I did a "set charset utf8" at the beginning of the page call before any other queries and that worked just peachy. cool.