]> granicus.if.org Git - php/commitdiff
Add is_unicode(), is_binary() and is_buffer()
authorMarcus Boerger <helly@php.net>
Sat, 13 Aug 2005 10:16:04 +0000 (10:16 +0000)
committerMarcus Boerger <helly@php.net>
Sat, 13 Aug 2005 10:16:04 +0000 (10:16 +0000)
ext/standard/basic_functions.c
ext/standard/php_type.h
ext/standard/type.c

index 966177b710db0727d94899b4fda0e261bd898125..e758b2d3e3e31887f94d3934d55c457aea352817 100644 (file)
@@ -531,6 +531,9 @@ function_entry basic_functions[] = {
        PHP_FALIAS(is_real,                             is_float,                                                               NULL)
        PHP_FE(is_numeric,                                                                                                              NULL)
        PHP_FE(is_string,                                                                                                               NULL)
+       PHP_FE(is_unicode,                                                                                                      NULL)
+       PHP_FE(is_binary,                                                                                                               NULL)
+       PHP_FE(is_buffer,                                                                                                               NULL)
        PHP_FE(is_array,                                                                                                                NULL)
        PHP_FE(is_object,                                                                                                               NULL)
        PHP_FE(is_scalar,                                                                                                               NULL)
index c68a65637bc2b7d544e1a6c2f6d9244d5f9a0088..07da585fc06ffb11797bb0467e070fa33573f178 100644 (file)
@@ -33,6 +33,9 @@ PHP_FUNCTION(is_long);
 PHP_FUNCTION(is_float);
 PHP_FUNCTION(is_numeric);
 PHP_FUNCTION(is_string);
+PHP_FUNCTION(is_unicode);
+PHP_FUNCTION(is_binary);
+PHP_FUNCTION(is_buffer);
 PHP_FUNCTION(is_array);
 PHP_FUNCTION(is_object);
 PHP_FUNCTION(is_scalar);
index c0e4d15cf6df6cb24fb309f9aefbf62cd9193440..70c1b39e6c603946bc6ddf0bef942dd3045c5471 100644 (file)
@@ -285,13 +285,47 @@ PHP_FUNCTION(is_float)
 /* }}} */
 
 /* {{{ proto bool is_string(mixed var)
-   Returns true if variable is a string */
+   Returns true if variable is a standard string */
 PHP_FUNCTION(is_string)
 {
        php_is_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, IS_STRING);
 }
 /* }}} */
 
+/* {{{ proto bool is_unicode(mixed var)
+   Returns true if variable is a unicode string */
+PHP_FUNCTION(is_unicode)
+{
+       php_is_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, IS_UNICODE);
+}
+/* }}} */
+
+/* {{{ proto bool is_binary(mixed var)
+   Returns true if variable is a binary string */
+PHP_FUNCTION(is_binary)
+{
+       php_is_type(INTERNAL_FUNCTION_PARAM_PASSTHRU, IS_BINARY);
+}
+/* }}} */
+
+/* {{{ proto bool is_buffer(mixed var)
+   Returns true if variable is a ascii, unicode or binary string */
+PHP_FUNCTION(is_buffer)
+{
+       pval **arg;
+
+       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only one argument expected");
+               RETURN_FALSE;
+       }
+
+       if (Z_TYPE_PP(arg) == IS_STRING || Z_TYPE_PP(arg) == IS_UNICODE || Z_TYPE_PP(arg) == IS_BINARY) {
+               RETURN_TRUE;
+       }
+       RETURN_FALSE;
+}
+/* }}} */
+
 /* {{{ proto bool is_array(mixed var)
    Returns true if variable is an array */
 PHP_FUNCTION(is_array)