php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45659 wrong size of japanese character
Submitted: 2008-07-30 07:56 UTC Modified: 2008-07-31 22:08 UTC
From: cuichangjie at gmail dot com Assigned: sixd (profile)
Status: Closed Package: OCI8 related
PHP Version: 5.2.6 OS: windows xp
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: cuichangjie at gmail dot com
New email:
PHP Version: OS:

 

 [2008-07-30 07:56 UTC] cuichangjie at gmail dot com
Description:
------------
When insert some japanese charectar (encoding type is "SJIS") using OCIBindByName and oci_execute, oracle has return the ORA-12899 error,it is seems like some addition bytes has been added after OCIBindByName.

Reproduce code:
---------------
//a table with 2 column, 
//empno -- number(1)
//ename -- varchar2(6)
$stmt = oci_parse($conn, " INSERT INTO                                    emp (empno, ename)  VALUES( :0, :1)");

$ret = OCIBindByName(stmt, ':0', 1);
//error check
...
$ret = OCIBindByName(stmt, ':1', '日本語');
//error check
...

$ret = oci_execute($stmt);

//error check
...


oracle's error shows :
ORA-12899: value too large for column "USER0"."MyTable"."ename" (actual: 9, maximum: 6)]

Expected result:
----------------
The string: '日本語' should be 6 bytes, 
echo strlen('日本語'); //should show us : 6



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-30 20:08 UTC] sixd@php.net
Please give Oracle DB and Oracle client versions.  What is the DB character set and what are the NLS settings used by PHP?  Do you specify a character set in oci_connect()?
 [2008-07-31 04:27 UTC] cuichangjie at gmail dot com
Oracle DB                   : 10.2.0.1.0
Oracle client versions      : 10.2.0.1.0
What is the DB characterset : AL32UTF8
NLS settings used by PHP    : putenv("NLS_LANG=Japanese_Japan.JA16SJIS");
Do you specify a character set in oci_connect(): no

I see the problem what is, the putenv() set a wrong characterset for DB, when i have changed putenv() to AL32UTF8, the strlen() can get the same length with db for janji.
 [2008-07-31 22:08 UTC] cuichangjie at gmail dot com
It is my mistake for using wrong charset with DB.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 04:01:31 2025 UTC