Zend Framework - utf8 on localhost okay - utf8 does not work on the web server

After searching for hours to resolve, I give up. Here is my problem. My database is on localhost utf8_general_ci , in my application.ini application I wrote

 resources.db.params.charset = utf8 

Everything is working fine.

But on the web server, characters appear as ΒΌ or â. I commented on resources.db.params = utf8 and exited. If it is absent, the characters are good everywhere, but not in any form (labels or values). If it's on every character, it looks like this. Same story / no effect with

 $form->setAttrib('accept-charset', 'UTF-8'); 

I also tried

 resources.db.params.driver_options = "SET NAMES utf8". 

without success.

PHP version of localhost: 5.3.8 - MySql 5.0.8
Web server PHP version: 5.2.6 - MySql 5.0.51

+4
source share
2 answers

I'm not sure if this is a solution, but to use UTF-8 in MySQL, I set the db parameter as follows:

 resources.db.params.charset = utf8 

Have you tried this?

[EDIT]

You can also make sure that the view (and therefore the form) also uses the correct encoding:

 resources.view.encoding = "UTF-8" 

Or, if you instantiate the view manually in bootstrap:

 $view->setEncoding("UTF-8"); 

This should force the form to accept the same encoding, since it uses the default view.

+3
source

Provided that your database is correctly configured to use the utf8_general_ci setting, the problem is not so much in the database as in telling the browser how to correctly decode the HTML response from the server.

There are two ways to tell the browser how to decode the response:

  • Enable character encoding in Content-Type -header. Then it will look something like this: Content-Type: text/html; charset=utf-8 Content-Type: text/html; charset=utf-8

    or similarly for another type of content.

    Content-Type: application/json; charset=utf-8

  • Include <meta charset="utf-8"> as the first tag in the <head> -tag. It is important to place this tag as one of the first tags. At least before any tag containing text that should be displayed, for example, <title> .

0
source

Source: https://habr.com/ru/post/1432932/


All Articles