I've been scratching my head for a while now, and I'm hoping that someone can push me in the right direction.
I have an Oracle DB that contains account information like Name, Surname, etc., and if I run the following (pseudo-)code:
<?php
$db = "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=myHost)(PORT=myPort)))(CONNECT_DATA=(SERVICE_NAME=myServiceName)))";
oci_connect("user","pass",$db,'AL32UTF8');
$query="
SELECT
//tried this
lastname AS LAST_NAME
//tried this:
(convert(lastname,'AL32UTF8')) AS LAST_NAME
FROM
SomeDb
WHERE
SomeId = 1234
";
$stid = oci_parse($c1, $query);
oci_execute($stid);
$row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS);
echo $row['LAST_NAME']; //returns �¼
echo utf8_decode($row['LAST_NAME']); // returns ür
echo utf8_encode($row['LAST_NAME']); // returns ���¼
it returns ü
characters back as: �¼
, while ë
characters are being displayed correctly.
I've checked the NLS_CHARACTERSET
of the Oracle server which is set to: AL32UTF8
.
I also checked the Apache charset config:
curl -A "Mozilla/4.0" http://localhost -I
HTTP/1.1 200 OK
Date: Tue, 05 Sep 2017 13:08:01 GMT
Server: Apache/2.4.10 (Debian)
Content-Type: text/html; charset=UTF-8
I tried to set internal coding:
mb_internal_encoding("UTF-8"); // this seemed to be default UTF-8.
I tried several setenv
values, but it seems nothing really works. What could be the problem? Am i overlooking something?
Additional info:
PHP -v
PHP 5.6.30-0+deb8u1
OCI8
OCI8 Version 2.0.8
In addition; I tried the following piece of code to find the correct encoding which gave me always
UTF-8
. If i moved theUTF-8
further back in the array it always gave meISO-8859-1
. So it turned out useless.Further research didn't come up with a cause or solution, so i decided to have the source characters in the Oracle database adjusted to the correct character.
I know it's not really the solution i wanted but since the amount of characters that were showing this weird translation were very low that was the quickest solution.
Thanks to all that have been thinking along with me.
Regards,
Frans