Re: cvs: php-src /ext/standard string.c
| From: | Andrei Zmievski | Date: | Fri, 09 Sep 2005 14:10:38 +0000 |
| Subject: | Re: cvs: php-src /ext/standard string.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-33874@lists.php.net to get a copy of this message | ||
Rolland,
+PHPAPI void php_unify_string_types(zval **p, zval **q TSRMLS_DC) +{There is an API function zend_get_best_string_type(). It will figure out the optimal string type based on the strings passed to it. Then you can use that optimal type to unify them via convert_to_explicit_type() function.+ if (p == NULL || q == NULL) { + return; + }++ if (Z_TYPE_PP(p) == IS_UNICODE) { + if (Z_TYPE_PP(q) == IS_BINARY) { + convert_to_binary_ex(p); + } else { + convert_to_unicode_ex(q); + } + } else if (Z_TYPE_PP(p) == IS_BINARY) { + convert_to_binary_ex(q); + } else { + if (Z_TYPE_PP(q) == IS_BINARY) { + convert_to_binary_ex(p); + } else { + convert_to_string_ex(q); + } + }+} +/* {{{ */
+ if (Z_TYPE_PP(str) == IS_UNICODE) {
+ i = 0; str_codepts = 0;
+ while (i < Z_USTRLEN_PP(str)) {
+ U16_FWD_1(Z_USTRVAL_PP(str), i, Z_USTRLEN_PP(str));
+ str_codepts++;
+ }
+ } else {
+ str_codepts = Z_STRLEN_PP(str);
+ }
u_countChar32() again would help.
-Andrei
On Sep 7, 2005, at 10:05 PM, Rolland Santimano wrote:
<rolland-20050908010538.txt>