php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17381 OCI fetch routines not working with UTF8 DB
Submitted: 2002-05-23 05:32 UTC Modified: 2003-10-14 21:00 UTC
Votes:16
Avg. Score:4.9 ± 0.2
Reproduced:14 of 14 (100.0%)
Same Version:5 (35.7%)
Same OS:4 (28.6%)
From: robert dot earls at lsi dot co dot uk Assigned:
Status: Not a bug Package: OCI8 related
PHP Version: 4.2.1 OS: Win NT
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: robert dot earls at lsi dot co dot uk
New email:
PHP Version: OS:

 

 [2002-05-23 05:32 UTC] robert dot earls at lsi dot co dot uk
I seem to be unable to return un-corrupted data from a UTF8 Oracle database.

Consider this example:-  (appologies for debugging)

<?
putenv("NLS_LANG=American_America.UTF8");
mb_internal_encoding("UTF-8");
$sql = "select dump(mycolumn) dump, mycolumn from my_table";
$link = OCIplogon("user","pass","connection");
//OCIInternalDebug(1);
$parse = OCIParse($link,$sql);
OCIExecute($parse);
if (OCIFetch($parse))
{
	$mycolumn = OCIResult($parse, "mycolumn");
	$mycolumndump = OCIResult($parse, "DUMP");
	print "found:";
	print bin2hex($mycolumn);
	print ": ".$mycolumn." : len = ".mb_strlen($mycolumn);
	print "<br><br>";
	print $mycolumndump;
	print "<br><br>";
	print mb_detect_encoding($mycolumn, "auto");
	print "<br><br>";
	print mb_internal_encoding();
	print "<br><br>";
	print_r( mb_get_info("all"));

}
?>

e.g.
If mycolumn contains a single UTF8 character E594B4 (three bytes)

I get the result:-

found:bf {upsidedown question mark} len=1

Typ=1 Len=3 228,148,180
EUC-JP
UTF-8

-

I would have expected to see:

found:e594b4 {a japanese glyph} len=3

I suppose the question is, does the OCI interface work correctly with multi-byte strings?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-23 06:50 UTC] robert dot earls at lis dot co dot uk
Can I just point out that I have used putenv, to set NLS_LANG in the example, because I thought that the system-wide environment variable $NLS_LANG was not being picked up.  It is currently set to "American_America.UTF8".
 [2003-10-14 21:00 UTC] sniper@php.net
Too old version (we're at 4.3.3 now) and also, the environment variables HAVE to be set in the shell, NOT in the script.
They won't work otherwise.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 15:01:30 2025 UTC