How to set charset to UTF-8 in a Zend application?

前端 未结 9 1409
失恋的感觉
失恋的感觉 2021-01-05 14:29

I am developping a Zend application. The data in my database is encoded in \"utf8_unicode_ci\". I declared in my application.ini :

resources.view.encoding =          


        
相关标签:
9条回答
  • 2021-01-05 15:12

    I had the same problem, i fixed it in config/autoload/global.php by setting charset value :

    'db' => [
        'adapters' => [
            'dummy' => [],
            'myadapter' => ['charset'  => 'utf-8',],
        ],
    
    0 讨论(0)
  • 2021-01-05 15:12

    I used to develop ZF application with many languages including RTL ones . and I used to add this to my bootstrap file and I've found it pretty neat .

    maybe this not an answer but i think its good suggestion :

    public function _initMB(){
     mb_internal_encoding("UTF-8");
    }
    

    for more info about mb_internal_string check out : http://php.net/manual/en/function.mb-internal-encoding.php

    0 讨论(0)
  • 2021-01-05 15:13

    Have you set the following, to fetch data from MySQL as utf8?

    resources.db.params.charset = "utf8"
    

    It is necessary to do three things to get correct characters displaying correctly:

    1. Save PHP/HTML files in utf8 encoding
    2. Fetch data from MySQL as utf8
    3. Send the right content-type / charset header or use a meta tag

    Further information in Rob Allen's article.

    0 讨论(0)
提交回复
热议问题