title: php-oci8 encoding issue
body: <p>Similar questions have been asked, but the regular solutions do not work for me. Probably I am missing something. I am about to loose my mind :(((</p>
  
  <p>As you can understand it from the title, I have an <strong>oracle</strong> database with non-ascii content. I want to query/display it with <strong>php</strong> using <strong>oci8</strong>.</p>
  
  <p>First of all, the database is in ISO8859P9, i.e. the query</p>
  
  <pre><code>select parameter, value from v$nls_parameters where parameter in ('NLS_CHARACTERSET', 'NLS_LANGUAGE', 'NLS_TERRITORY')
  </code></pre>
  
  <p>returns</p>
  
  <pre><code>NLS_LANGUAGE        AMERICAN
  NLS_TERRITORY       AMERICA
  NLS_CHARACTERSER    WE8ISO8859P9
  </code></pre>
  
  <p>So I have set up NLS_LANG variable accordingly, i.e. getenv("NLS_LANG") returns "AMERICAN_AMERICA.WE8ISO8859P9".</p>
  
  <p>I inserted <code>AddDefaultCharset ISO-8859-9</code> to /etc/apache2/conf.d/charset file, and I always included <code>&lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-9"&gt;</code> in head section of html content of php files. So when I check via firebug, I see that the "Content-Type" header for a response is "text/html; charset=ISO-8859-9".</p>
  
  <p>Lastly, I have a line as <code>default_charset = "ISO-8859-9"</code> in /etc/php5/apache2/php.ini file, and in the core section of the output phpinfo(), I see that default_charset is ISO-8859-9.</p>
  
  <p>After all these stuff, when I retrieve a string with a character <code>İ</code> in it and echo it, it is shown as '?'. That is the problem!!! When I query <code>select dump(nameofthatstring, 16)...</code>, I see that its byte value is DD, i.e. correct according to 8859-9.</p>
  
  <p>I am not sure whether it is relevant but, I will give a final detail: When I enter a character <code>ı</code> in a form and submit it via ajax in GET, it is converted to %FD, i.e. the 8859-9 corresponding value, no problem. </p>
  
  <p>When I urldecode it and echo it, it is again ok, I see <code>ı</code>. But when I have a query with a string containing <code>ı</code> in its where clause (after receiving the ajax request), it returns empty set. </p>
  
  <p>However, if I select the rows using CHR(253), the rows are selected correctly, but printing these rows again results in '?' characters.</p>
  
  <p>I am really stuck. Any help will be highly appreciated.
  Thanks in advance.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <pre><code>$database = "(DESCRIPTION= (ADDRESS= (PROTOCOL=TCP)(HOST=XXXX)(PORT=1521)) (CONNECT_DATA= (SERVER=dedicated)(SERVICE_NAME=sname)))";
  </code></pre>
  
  <p>First, I have tried this:</p>
  
  <pre><code>oci_pconnect($username, $password, $database, "AMERICAN_AMERICA.WE8ISO8859P9");
  </code></pre>
  
  <p>But it did not solve, so I set NLS_LANG variable and changed to the following:</p>
  
  <pre><code>oci_pconnect($username, $password, $database);
  </code></pre>
  
  <p>Nothing changed...</p>