Encoding ZF2-对表单中的标签进行编码

Encoding ZF2-对表单中的标签进行编码,encoding,zend-framework2,Encoding,Zend Framework2,当我的整个系统(页面和服务器)都是法语并且采用ISO-8859-15编码时,我使用ZF2创建了一个表单。我没有能力更改这种编码,所以我想我们必须处理ANSI 问题是,在创建表单时,我使用以下代码: public function createAction() { BootstrapLogger::info(__METHOD__); $this->layout( 'layout/xhtml' ); $dbAdapter = $this->getServiceLo

当我的整个系统(页面和服务器)都是法语并且采用ISO-8859-15编码时,我使用ZF2创建了一个表单。我没有能力更改这种编码,所以我想我们必须处理ANSI

问题是,在创建表单时,我使用以下代码:

public function createAction() {
    BootstrapLogger::info(__METHOD__);
    $this->layout( 'layout/xhtml' );
    $dbAdapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');;
    $form = new ActionForm($dbAdapter);

    $form->get('submit')->setValue('Créer');

} 
并获取以下错误:

Message:
String to be escaped was not valid UTF-8 or could not be converted: Crï¿œer
我真的不明白为什么,也不知道如何避免这种情况

我猜这与创建表单时标签编码错误的原因相同

  $this->add( array(
            'name' => 'act_num',
            'type' => 'Text',
            'options' => array(
                'label' => "N° action",
            ),
            'attributes' => array(
                'disabled' => 'disabled',
                'class' => 'form-control'
            )
        ));

    //ch2 - Libellé de l'action
    $this->add( array(
            'name' => 'act_label',
            'type' => 'Text',
            'options' => array(
                'label' => "Libellé de l'action",
            ),
            'attributes' => array(
                'required' => 'required',
                'class' => 'form-control'
            )
        ));
这会给我

  Nᅵ action
  Libellᅵ de l'action
select的内容也存在同样的问题(由SQLDb[在拉丁语1\u general\u ci中]填充)

你知道怎么解决这个问题吗


非常感谢您为表单指定不同的编码。不确定如何使用InputFilter,因为有几种不同的方法,但为每个字段添加此方法

'validators' => [
    [
        'name'    => 'StringLength',
        'options' => [
            'encoding' => 'UTF-8',
            'min' => 1,
        ],
    ],
],

尝试为表单指定不同的编码。不确定如何使用InputFilter,因为有几种不同的方法,但为每个字段添加此方法

'validators' => [
    [
        'name'    => 'StringLength',
        'options' => [
            'encoding' => 'UTF-8',
            'min' => 1,
        ],
    ],
],