Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:32817 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9099 invoked by uid 1010); 16 Oct 2007 20:35:19 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 9084 invoked from network); 16 Oct 2007 20:35:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Oct 2007 20:35:19 -0000 Authentication-Results: pb1.pair.com header.from=christopher.jones@oracle.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=christopher.jones@oracle.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain oracle.com from 148.87.113.118 cause and error) X-PHP-List-Original-Sender: christopher.jones@oracle.com X-Host-Fingerprint: 148.87.113.118 rgminet01.oracle.com Linux 2.4/2.6 Received: from [148.87.113.118] ([148.87.113.118:31537] helo=rgminet01.oracle.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9B/4B-30952-68025174 for ; Tue, 16 Oct 2007 16:35:19 -0400 Received: from agmgw1.us.oracle.com (agmgw1.us.oracle.com [152.68.180.212]) by rgminet01.oracle.com (Switch-3.2.4/Switch-3.1.6) with ESMTP id l9GKZBJT024150 for ; Tue, 16 Oct 2007 14:35:11 -0600 Received: from acsmt353.oracle.com (acsmt353.oracle.com [141.146.40.153]) by agmgw1.us.oracle.com (Switch-3.2.0/Switch-3.2.0) with ESMTP id l9GKZ9uL017076 for ; Tue, 16 Oct 2007 14:35:09 -0600 Received: from dhcp-emea-uk-csvpn-gw8-141-144-138-50.vpn.oracle.com by acsmt356.oracle.com with ESMTP id 5235882151192566825; Tue, 16 Oct 2007 13:33:45 -0700 Message-ID: <47152024.4010904@oracle.com> Date: Tue, 16 Oct 2007 13:33:40 -0700 User-Agent: Thunderbird 1.5.0.13 (X11/20070824) MIME-Version: 1.0 To: internals@lists.php.net Content-Type: multipart/mixed; boundary="------------010402090801080002040602" X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-Whitelist: TRUE Subject: Using OnUpdateUTF8String in PHP 6 From: christopher.jones@oracle.com (Christopher Jones) --------------010402090801080002040602 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit With thanks to Sara we looked at OnUpdateUTF8String to access a php.ini value in OCI8 in PHP 6. One of our engineers sent me a proposed patch for zend_ini.c in PHP6 to allow OnUpdateUTF8String to work as he thought it should. Any comments? Chris ------------ > The problems I faced when unicode.semantics=On were: > > 1) Any OnUpdateUTF8String php.ini variable is seen as NULL in > oci_globals. > > 2) If the above is resolved, the memory of the variable is wiped out, > by the time we come to execution of the script, after module inits. > > 3) We still convert to UTF-16 when unicode.semantics=Off. PS. Patch is attached - if it gets through. -- Christopher Jones, Oracle Email: christopher.jones@oracle.com Tel: +1 650 506 8630 Blog: http://blogs.oracle.com/opal/ Free PHP Book: http://tinyurl.com/f8jad --------------010402090801080002040602 Content-Type: text/plain; name="zend_ini.c.diff.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="zend_ini.c.diff.txt" --- zend_ini.c 2007-10-02 11:07:32.000000000 -0700 +++ zend_ini.c.new 2007-10-16 13:20:03.000000000 -0700 @@ -640,7 +640,8 @@ ZEND_API ZEND_INI_MH(OnUpdateUTF8String) /* {{{ */ { - UChar **p; + UChar **up; + char **p; UChar *ustr = NULL; int32_t ustr_len, capacity; UErrorCode status = U_ZERO_ERROR; @@ -651,30 +652,37 @@ base = (char *) ts_resource(*((int *) mh_arg2)); #endif + /* Convert only if unicode semantics is on. Otherwise, same as OnUpdateString */ + if (UG(unicode)){ + /* estimate capacity */ + capacity = (new_value_length > 2) ? ((new_value_length >> 1) + (new_value_length >> 3) + 2) : new_value_length; + + while (1) { + ustr = peurealloc(ustr, capacity+1, 1); + u_strFromUTF8(ustr, capacity+1, &ustr_len, new_value, new_value_length, &status); + if (status == U_BUFFER_OVERFLOW_ERROR || status == U_STRING_NOT_TERMINATED_WARNING) { + capacity = ustr_len; + status = U_ZERO_ERROR; + } else { + break; + } + } - /* estimate capacity */ - capacity = (new_value_length > 2) ? ((new_value_length >> 1) + (new_value_length >> 3) + 2) : new_value_length; - - while (1) { - ustr = eurealloc(ustr, capacity+1); - u_strFromUTF8(ustr, capacity, &ustr_len, new_value, new_value_length, &status); - if (status == U_BUFFER_OVERFLOW_ERROR) { - capacity = ustr_len; - status = U_ZERO_ERROR; - } else { - break; + if (U_FAILURE(status)) { + zend_error(E_WARNING, "Could not convert UTF-8 INI value to Unicode"); + efree(ustr); + return FAILURE; } - } - if (U_FAILURE(status)) { - zend_error(E_WARNING, "Could not convert UTF-8 INI value to Unicode"); - efree(ustr); - return FAILURE; - } + up = (UChar **) (base+(size_t) mh_arg1); - p = (UChar **) (base+(size_t) mh_arg1); + *up = ustr; + } + else { /* Same as OnUpdateString */ + p = (char **) (base+(size_t) mh_arg1); - *p = ustr; + *p = new_value; + } return SUCCESS; } /* }}} */ --------------010402090801080002040602--