Rolland,
+PHPAPI void php_unify_string_types(zval **p, zval **q TSRMLS_DC)
+{
+ 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);
+ }
+ }
+}
+/* {{{ */
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 (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>
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php