Question

$userTb = new My_Tb_User();  //Child of Zend_Db_Table_Abstract
$row = $userTb->find(9)->current();
$row->name = 'STÖVER';
$row->save();

Inside user table at row 9 for name column value ST gets stored instead of STÖVER ?

Ö is a german character supported in UTF-8 . IF I enter manually 'STÖVER' using phpmyadmin it get stored correctly .

I also passed charset parameter with value utf8 when creating db adapter but still no luck !

Was it helpful?

Solution 2

This is a bad practice to use utf8_encode, this adds a lot of complexity to your app. Try to solve the problem by looking for the source.

Ssome thoughts :

  • a database server charset problem (check encoding of your server)
  • a database client charset problem (check encoding of your connection)
  • a database table charset problem (check encoding of your table)
  • a php default encoding problem (check default_encoding parameter in parameters.ini)
  • a multibyte missconfigured (see mb_string parameters in parameters.ini)
  • a <form> charset problem (check that it is sent as utf-8)
  • a <html> charset problem (where no enctype is set in your html file)
  • a Content-encoding: problem (where the wrong encoding is sent by Apache).

OTHER TIPS

If you read the manual entry for utf8_encode, it converts an ISO-8859-1 encoded string to UTF-8. The function name is a horrible misnomer, as it suggests some sort of automagic encoding that is necessary. That is not the case. If your source code is saved as UTF-8 and you assign "STÖVER" to $string, then $string holds the character "STÖVER" encoded in UTF-8. No further action is necessary. In fact, trying to convert the UTF-8 string (incorrectly) from ISO-8859-1 to UTF-8 will garble it.

utf8_encode('STÖVER');

check this question in stackoverflow

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top