|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-10-10 02:11 UTC] jhtpeter at gmail dot com
Description: ------------ I use oic(Oracle Instance Client) to call php-oci functions with php 5.2.x-dev. The Oracle10g Database Server Charset is AL32UTF8. The Web Env NLS_LANG is "SIMPLIFIED CHINESE_CHINA.ZHS16GBK". When i get CLOB use oci_fetch_array with options OCI_RETURN_LOBS, php return incorrect charset. While VARCHAR2 COLUMN is correct. The same to oci_fetch_all. Reproduce code: --------------- $sql = "SELECT VARCHAR2_TITLE, CLOB_CONTENT FROM TEST"; oci_prase... oci_fetch_array... Expected result: ---------------- VARCHAR2_TITLE: ????(correct charset in ZHS16GBK) CLOB_CONTENT: ????(correct charset in ZHS16GBK) Actual result: -------------- VARCHAR2_TITLE: ????(correct charset in ZHS16GBK) CLOB_CONTENT: ????(incorrect charset in AL32UTF8) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 03:00:02 2025 UTC |
I'm sorry about this. Description: ------------ I use oic(Oracle Instance Client) to call php-oci functions with php 5.2.x-dev. The Oracle10g Database Server Charset is AL32UTF8. The Web Env NLS_LANG is "SIMPLIFIED CHINESE_CHINA.ZHS16GBK". When i get CLOB content, php return incorrect charset string, while VARCHAR2 COLUMN is correct. CREATE TABLE TEST (TITLE VARCHAR2(100) NULL, CONTENT CLOB NULL); INSERT INTO TEST ('????', '??????????'); COMMIT; Reproduce code: --------------- <?php $conn = oci_connect('scott', 'tiger', '//localhost:1521/ORCL10G'); $stmt = oci_parse($conn, 'SELECT TITLE, CONTENT FROM TEST'); oci_execute($stmt, OCI_DEFAULT); while ($row = oci_fetch_array($stmt, (OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS))) { echo 'VARCHAR2_TITLE: ' . $row['TITLE'] . '<br>'; echo 'CLOB_CONTENT: ' . $row['CONTENT'] . '<br>'; } ?> Expected result: ---------------- VARCHAR2_TITLE: ???? CLOB_CONTENT: ?????????? Actual result: -------------- VARCHAR2_TITLE: ???? (correct) CLOB_CONTENT: ????? (incorrect)i'm experiencing the same problem with RHEL305/php5.1.6. The php build is one of my own and i've replaced the oci8 module with the one from pecl (oci8 1.2.2). I'm compiling against Oracle Instantclient 10.2. My NLS_LANG ist set to AMERICAN_AMERICA.UTF8. select * from nls_database_parameters where parameter='NLS_CHARACTERSET' returns WE8ISO8859P1 as expected. TIA & Kind Regards Lucas Bickel Reproduce Code: -------------- <?php $c = OCILogon('scott', 'tiger', 'sample'); $sql = "CREATE TABLE TEST_TABLE (TITLE VARCHAR2(100) NULL, CONTENT CLOB NULL)"; $s = OCIParse($c, $sql); OCIExecute($s); $sql = "INSERT INTO TEST_TABLE (TITLE, CONTENT) VALUES ('???', 'some text with some umlauts ???')"; $s = OCIParse($c, $sql); OCIExecute($s); $sql = 'COMMIT'; $s = OCIParse($c, $sql); OCIExecute($s); $sql = "SELECT TITLE, CONTENT FROM TEST_TABLE"; $s = OCIParse($c, $sql); $lob = OCINewDescriptor($c, OCI_D_LOB); OCIDefineByName($s, 'CONTENT', $lob); OCIExecute($s); while (OCIFetchInto($s, &$r, OCI_ASSOC+OCI_RETURN_NULLS)) { echo 'VARCHAR_CHARSET: '.mb_detect_encoding($r['TITLE'], 'UTF8, LATIN1')."\n"; echo 'CLOB_CHARSET: '.mb_detect_encoding($r['CONTENT']->load(), 'UTF8, LATIN1')."\n"; } ocifreestatement($s); OCILogoff($c); ?> Expected output: ---------------- VARCHAR_CHARSET: UTF-8 CLOB_CHARSET: UTF-8 Actual output: -------------- VARCHAR_CHARSET: UTF-8 CLOB_CHARSET: ISO-8859-1 i added mb_detect_encoding for convenience, it reproduces just fine without.