]> granicus.if.org Git - php/commitdiff
- Make ord() work on binary strings too.
authorDerick Rethans <derick@php.net>
Thu, 8 Sep 2005 14:07:40 +0000 (14:07 +0000)
committerDerick Rethans <derick@php.net>
Thu, 8 Sep 2005 14:07:40 +0000 (14:07 +0000)
ext/standard/string.c

index bafb7d608f55f66873649d5e610b6656f9ee1319..29da37969106cfd8bfff18c1eee7d2e6a896a993 100644 (file)
@@ -2902,8 +2902,12 @@ PHP_FUNCTION(ord)
        if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &str) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
-       convert_to_text_ex(str);
 
+       if (Z_TYPE_PP(str) == IS_BINARY) {
+               RETURN_LONG((unsigned char) Z_STRVAL_PP(str)[0]);
+       }
+
+       convert_to_text_ex(str);
        if (Z_TYPE_PP(str) == IS_UNICODE) {
                RETURN_LONG(zend_get_codepoint_at(Z_USTRVAL_PP(str), Z_USTRLEN_PP(str), 0));
        } else {