|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-02-28 23:23 UTC] tony2001@php.net
[2005-03-01 03:34 UTC] bmr at comtime dot com
[2005-09-08 11:47 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 23:00:01 2025 UTC |
Description: ------------ NVARCHAR2 columns can be used to store UTF-8 or UTF-16 characters. When using UTF-8 it can take 3 (or more??) bytes to represent one character. PHP truncates strings that have byte representations longer than 2 times the character length. This is actually an Oracle bug because the OCI call returns the wrong byte length. Here's my patch: --- php-4.3.10/ext/oci8/oci8.c Wed Nov 3 08:35:56 2004 +++ php-4.3.10.cti/ext/oci8/oci8.c Mon Feb 28 15:37:54 2005 @@ -1443,6 +1443,7 @@ ub4 iters; ub4 colcount; ub2 dynamic; + ub1 charset_form; int dtype; dvoid *buf; oci_descriptor *descr; @@ -1573,6 +1574,21 @@ return 0; /* XXX we loose memory!!! */ } + if(outcol->data_type == SQLT_CHR) { + CALL_OCI_RETURN(error, OCIAttrGet( + (dvoid *)param, + OCI_DTYPE_PARAM, + (dvoid *)&charset_form, + (dvoid *)0, + OCI_ATTR_CHARSET_FORM, + statement->pError)); + statement->error = oci_error(statement->pError, "OCIAttrGet OCI_DTYPE_PARAM/OCI_ATTR_CHARS ET_FORM", error); + if (statement->error) { + oci_handle_error(statement->conn, statement->error); + return 0; /* XXX we loose memory!!! */ + } + } + CALL_OCI_RETURN(error, OCIAttrGet( (dvoid *)param, OCI_DTYPE_PARAM, @@ -1700,6 +1716,9 @@ ) { outcol->storage_size4 = 512; /* XXX this should fit "most" NLS date-formats and Numbers */ } else { + if(charset_form == SQLCS_NCHAR) + outcol->storage_size4 *=2; /* double for unicode */ + outcol->storage_size4++; /* add one for string terminator */ } if (outcol->data_type == SQLT_BIN) { Reproduce code: --------------- ocifetchinto()