These settings work for me:

[client]
default_character_set = utf8

[mysqld]
character_set_server = utf8
collation_server = utf8_unicode_ci
skip-character-set-client-handshake

When PHP connects it seems to set the connection to latin1. The
"skip-character-set-client-handshake" option will make mysql ignore this and
use the default which is set to utf8. If that doesn't work then you could
also try:

[mysqld]
init-connect='SET NAMES utf8' 


Martin Carpentier wrote:
> 
> I've looked for a solution to this problem a while ago.
> 
> The MySQL documentation mention somewhere to set a parameter in the config
> in order to fix it or to use "SET CHARACTER SET utf8".
> I tried the config way but no matter what I tried it didn't work so I
> resorted to use the query fix.
> 
> I don't understand why it's so complicated to make MySQL run in UTF-8.
> 
> Martin
> 
> 
> 
> On 10/15/07, Simon Mundy <[EMAIL PROTECTED]> wrote:
>>
>> Hi Michael
>>
>> That's not necessarily true regarding UTF-8 on even Linux systems.
>>
>> I need to tell the MySQL client in Fedora Core 6 that it needs to run
>> in UTF8 before I start any queries:-
>>
>> $db->query('SET CHARACTER SET utf8');
>>
>> otherwise it will default to latin_swedish and become the weak link in
>> the chain.
>>
>> > On 10/14/07, debussy007 <[EMAIL PROTECTED]> wrote:
>> >>
>> >>
>> >> Like dinok said,
>> >> If I use $dbquery("SET NAMES 'utf8'");
>> >> I have it working.
>> >>
>> >> But does that still means I have garbage in my db ?
>> >>
>> >> Concretely I am storing the countries with their respective ISO
>> >> code from a
>> >> .csv file in my DB.
>> >
>> > Now I don't know. I've never heard of SET NAMES 'utf8'. Must be a
>> > Windows thing. On *nix systems everything runs in the UTF-8 locale [1]
>> > so it all Just Works. But if you have it working, you're good.
>> >
>> > Mike
>> >
>> > [1] except for the web server which usually runs in the C locale
>> > because it may need to handle many encodings simultaneously.
>> >
>> > --
>> > Michael B Allen
>> > PHP Active Directory SPNEGO SSO
>> > http://www.ioplex.com/
>>
>>
> 
> 
> -- 
> Martin Carpentier
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Best-place-to-specify-encoding-tf4621717s16154.html#a13610194
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to