title: Utf-8 characters displayed as ISO-8859-1
body: <p>I've got an issue with inserting/reading utf8 content from a db. All verifications I'm doing seem to point to the fact that the content in my DB should be utf8 encoded, however it seems to be latin encoded. The data are initially imported from a PHP script from the CLI.</p>
  
  <h2>Configuration:</h2>
  
  <pre><code>Zend Framework Version: 1.10.5
  mysql-server-5.0:   5.0.51a-3ubuntu5.7
  php5-mysql:     5.2.4-2ubuntu5.10
  apache2:        2.2.8-1ubuntu0.16
  libapache2-mod-php5:    5.2.4-2ubuntu5.10
  </code></pre>
  
  <h2>Vertifications:</h2>
  
  <p>-mysql:</p>
  
  <pre><code>mysql&gt; SHOW VARIABLES LIKE 'character_set%';
  +--------------------------+----------------------------+
  | Variable_name            | Value                      |
  +--------------------------+----------------------------+
  | character_set_client     | utf8                       |
  | character_set_connection | utf8                       |
  | character_set_database   | utf8                       |
  | character_set_filesystem | binary                     |
  | character_set_results    | utf8                       |
  | character_set_server     | utf8                       |
  | character_set_system     | utf8                       |
  | character_sets_dir       | /usr/share/mysql/charsets/ |
  +--------------------------+----------------------------+
  8 rows in set (0.00 sec)
  
  mysql&gt; SHOW VARIABLES LIKE 'collation%';
  +----------------------+-----------------+
  | Variable_name        | Value           |
  +----------------------+-----------------+
  | collation_connection | utf8_general_ci |
  | collation_database   | utf8_bin        |
  | collation_server     | utf8_general_ci |
  +----------------------+-----------------+
  </code></pre>
  
  <p>-database</p>
  
  <pre><code>created with 
  CREATE DATABASE mydb CHARACTER SET utf8 COLLATE utf8_bin;
  CREATE SCHEMA `mydb` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin ;
  
  mysql&gt; status;
  --------------
  mysql  Ver 14.12 Distrib 5.0.51a, for debian-linux-gnu (i486) using readline 5.2
  
  Connection id:          7
  Current database:       mydb
  Current user:           root@localhost
  SSL:                    Not in use
  Current pager:          stdout
  Using outfile:          ''
  Using delimiter:        ;
  Server version:         5.0.51a-3ubuntu5.7-log (Ubuntu)
  Protocol version:       10
  Connection:             Localhost via UNIX socket
  Server characterset:    utf8
  Db     characterset:    utf8
  Client characterset:    utf8
  Conn.  characterset:    utf8
  UNIX socket:            /var/run/mysqld/mysqld.sock
  Uptime:                 9 min 45 sec
  </code></pre>
  
  <p>-sql: before doing my inserts I run the </p>
  
  <pre><code>SET names 'utf8';
  </code></pre>
  
  <p>-php: before doing my inserts I use <strong>utf8_encode()</strong> and <strong>mb_detect_encoding()</strong> which gives me 'UTF-8'. After retrieveing the content from db and before sending it to the user mb_detect_encoding() also gives 'UTF-8'</p>
  
  <h2>Validation test:</h2>
  
  <p>the only way for me to have the content displayed properly is to set the content type to latin (If I sniff the traffic I can see the content-type header with ISO-8859-1):</p>
  
  <pre><code>ini_set('default_charset', 'ISO-8859-1');
  </code></pre>
  
  <p>This test shows that the content comes out as latin. I don't understand why. 
  Does anybody have any idea?</p>
  
  <p>Thanks.</p>