I have this code in drupal 6 to retrieve arabic values from Oracle databse:
<?php
session_start();
$conn=oci_connect('localhost','pass','IP....');
$stid=oci_parse($conn,"select arabic_name from arabic_names_table");
oci_execute($stid);
if($row-oci_fetch_array($stid,OCI_ASSOC+OCI_RETURNS_NULLS))
{
$name_ar=$row['arabic_name'];
}
?>
When values are retrieved from the DB or inserted to the DB they appears like this ???
Please note:
- My Oracle database reads normal Arabic characters. From PL/SQL I can insert arabic values
- I have installed the mbstring
- I have the utf-8 encoding enabled.
How can I solve this problem?
From the oracle database, when you try to fetch data, normally you will get the character encoding will be the encoding type of the client installed in the system (the machine that you installed the php). This encoding will be the charset of the windows registry for the oracle client. (see
HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraClient11g_home1), and the key isNLS_LANG. If you search the value of the above key, you will get something likeARABIC_UNITED ARAB EMIRATES.AR8MSWIN1256. Please note that the encoding type isAR8MSWIN1256. In the character map array this is mapped towindows-1256(windows-1256 => AR8MSWIN1256).See this link http://websvn.projects.ez.no/wsvn/ezoracle/?op=comp&compare%5B%5D=%2Fstable@385&compare%5B%5D=%2Fstable@386.
That is, after you fetch the data from the database the char encoding will be
windows-1256. Now if your web page is usingutf-8charset, you need to convert the string toutf-8. For this you can useiconv().If you are still facing problem you check the charset in the page, it must be
utf-8.<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />I think this will solve your problem.