what are the settings that i need to fix in php.ini, apache to show utf8 encoded text stored in oracle db to be displayed properly in a web page?
things i have done:
- default charset settings to utf8
- added explicit encoding in oci_connect
sample code:
$conn = oci_connect('xxxx', 'xxx', 'xxx', 'AL32UTF8');
if (!$conn) {
$e = oci_error();
echo "Connection failed: " . $e['message'];
exit;
}
// Set the NLS_LANG for the session
oci_execute(oci_parse($conn, "ALTER SESSION SET NLS_LANGUAGE='AMERICAN'"));
oci_execute(oci_parse($conn, "ALTER SESSION SET NLS_TERRITORY='AMERICA'"));
oci_execute(oci_parse($conn, "ALTER SESSION SET NLS_CHARACTERSET='AL32UTF8'"));
oci_set_client_info($conn, "NLS_LANG=AMERICAN_AMERICA.AL32UTF8");
mb_internal_encoding('UTF-8');
$query = 'SELECT * FROM ABC_TABLE';
$stid = oci_parse($conn, $query);
oci_execute($stid);
while (($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
foreach ($row as $item) {
echo htmlspecialchars($item, ENT_QUOTES, 'UTF-8') . "<br>\n";
echo htmlspecialchars($item, ENT_QUOTES | ENT_HTML5, 'UTF-8'). "<br>\n";
echo $item . "<br>\n";
echo mb_convert_encoding($item, 'UTF-8', 'auto') . "<br>\n";;
}
}
oci_free_statement($stid);
oci_close($conn);
output:
शà¥à¤°à¥€ कृषà¥à¤£ सिंह बसà¥à¤¨à¥‡à¤¤ / शà¥à¤°à¥€ सागर जà¥à¤žà¤µà¤¾à¤²à¥€
You need to sign in to view this answers