php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39103 Oracle CLOB Charset Incorrect
Submitted: 2006-10-10 02:11 UTC Modified: 2006-11-03 01:00 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: jhtpeter at gmail dot com Assigned: tony2001 (profile)
Status: No Feedback Package: OCI8 related
PHP Version: 5.2.0RC5 OS: Linux
Private report: No CVE-ID: None
 [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)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-10 02:18 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)
 [2006-10-10 08:52 UTC] tony2001@php.net
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 12:38 UTC] 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-12 10:04 UTC] tony2001@php.net
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-20 01:00 UTC] 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-26 16:41 UTC] lucas dot bickel at service dot rba dot ch
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.
 [2006-10-26 16:58 UTC] tony2001@php.net
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-11-03 01:00 UTC] 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".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC