Zend_Form中的非英文字符

时间:2011-05-13 12:16:57

标签: zend-framework encoding character-encoding zend-form

我正在使用Zend_Form创建一个表单,并且不会呈现包含变音符号的所有单词。编码设置为UTF-8,数据库的排序规则设置为utf-8_unicode。我还应该做什么/检查?

页眉:

<meta content="text/html; charset=utf-8" http-equiv="content-type">

Zend_form部分:

        $user = Doctrine::getTable("aclUser")->find(1, Doctrine_Core::HYDRATE_ARRAY);
        $this->addElement('text','providerName',
            array(
                'label'     => 'Provider_name',
                'required'  => false,
                'readonly'  => true,
                'value'     => $user['name'],
                'filters'   => array('StringTrim'),
                'decorators'=> array(new Application_Form_Decorators_Custom())
            )
        );

2 个答案:

答案 0 :(得分:1)

可能是提交表单本身的问题

将表单的accept-charset设置为UTF-8会有帮助吗?

<form accept-charset="UTF-8">
   [form elements]
</form>

答案 1 :(得分:1)

解决。我在 my.cnf 中添加了这些设置,现在一切正常:

[client] 
default-character-set=utf8 

[mysqld] 
init_connect='SET collation_connection = utf8_unicode_ci' 
init_connect='SET NAMES utf8' 
default-character-set=utf8 
character-set-server = utf8 
collation-server = utf8_unicode_ci 

[mysql] 
default-character-set=utf8