Hi, you already answered your question yourself.
You create your database handler via $db = ezcDbFactory::create( $dsn ); // see: http://ezcomponents.org/docs/api/trunk/Database/ezcDbFactory.html directly afterwards you issue $db->exec("SET NAMES 'utf8';"); The alternative is, to configure your database to use utf8 from the beginning. Please refer to the MySQL manual for this: http://dev.mysql.com/doc/refman/5.0/en/option-files.html http://dev.mysql.com/doc/refman/5.0/en/server- options.html#option_mysqld_character-set-server And please don't use windows do develop software. Best regards, Thomas Koch Am Monday 09 March 2009 02:03:37 schrieb chenlong85.2004: > ---------- 转发邮件信息 ---------- > 发件人:""chenlong85.2004" <[email protected]>" > 发送日期:2009-03-06 11:18:34 > 收件人:"Thomas Koch" <[email protected]> > 主题: Re:[Components] Chinese code question > > hi Thomas Koch ,thank you for your help! i only use PDO which connect mysql > encounter with the same problem that Chinese characters inserted are > garbled! so "$db = new PDO( $dsn,$admin,$pwd ); > $db->exec("SET NAMES 'utf8';");" Chinese characters are ok! i check mysql > that mysql> SHOW VARIABLES LIKE 'character%'; > +--------------------------+----------------------------------+ > > | Variable_name | Value | > > +--------------------------+----------------------------------+ > > | character_set_client | utf8 | > | character_set_connection | utf8 | > | character_set_database | utf8 | > | character_set_filesystem | binary | > | character_set_results | utf8 | > | character_set_server | utf8 | > | character_set_system | utf8 | > | character_sets_dir | d:\AppServ\MySQL\share\charsets\ | > > +--------------------------+----------------------------------+ > 8 rows in set (0.00 sec) > > however,if there is not $db->exec("SET NAMES 'utf8';");",Chinese characters > inserted are garbled! > > but if use database component, i don't konw how to set ("SET NAMES > 'utf8';");", thanks for your help! > > > 在2009-03-05,"Thomas Koch" <[email protected]> 写道: > > >Hi, > > > >you could get better answers, if you'd provide more accurate descriptions > > of your problems. > >However I believe that your problem is not related to eZ Components, but > > to some unintended character set conversion somewhere on the way. Please > > read > > http://koch.ro/blog/index.php?/archives/50-MySQL-character-sets-primer.ht > >ml and make sure, that mysql is configured the right way. > > > >Try to issue a > >set names utf8; > >statement at the beginning of your MySQL session. > > > >Best regards, > > > >Thomas Koch > > > >Am Thursday 05 March 2009 09:31:51 schrieb chenlong85.2004: > >> hi ,when i use database component, i find Chinese charactersinserted > >> into mysql are garbled. why ? who can help me !thank you ! > > > >-- > >Thomas Koch, http://www.koch.ro > >YMC AG, http://www.ymc.ch > > > >-- > >Components mailing list > >[email protected] > >http://lists.ez.no/mailman/listinfo/components > > 网易邮箱,中国第一大电子邮件服务商 -- Thomas Koch, http://www.koch.ro YMC AG, http://www.ymc.ch -- Components mailing list [email protected] http://lists.ez.no/mailman/listinfo/components
