ID: 39103
Comment by: lucas dot bickel at service dot rba dot ch
Reported By: jhtpeter at gmail dot com
Status: No Feedback
Bug Type: OCI8 related
Operating System: Linux
PHP Version: 5.2.0RC5
Assigned To: tony2001
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2006-10-20 01:00:00] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2006-10-12 10:04:28] [EMAIL PROTECTED]
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.2-win32-latest.zip
------------------------------------------------------------------------
[2006-10-10 12:38:48] jhtpeter at gmail dot com
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)
------------------------------------------------------------------------
[2006-10-10 08:52:51] [EMAIL PROTECTED]
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
------------------------------------------------------------------------
[2006-10-10 02:18:46] 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)
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/39103
--
Edit this bug report at http://bugs.php.net/?id=39103&edit=1