Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > Using OnUpdateUTF8String in PHP 6
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 12th August 03:20
christopher.jones
External User
 
Posts: 1
Default Using OnUpdateUTF8String in PHP 6



--------------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

------------

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
Content-Type: text/plain; charset=us-ascii

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
--------------010402090801080002040602--
  Reply With Quote


  sponsored links


2 13th August 04:06
andrei
External User
 
Posts: 1
Default Using OnUpdateUTF8String in PHP 6



Seems fine to me. Sara?

-Andrei
http://10fathoms.org/vu - daily photoblog

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666