From: Derick Rethans Date: Thu, 8 Sep 2005 14:07:40 +0000 (+0000) Subject: - Make ord() work on binary strings too. X-Git-Tag: RELEASE_0_9_0~256 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9d04a8e369081a1915b7b061b2b311bf606e4b7f;p=php - Make ord() work on binary strings too. --- diff --git a/ext/standard/string.c b/ext/standard/string.c index bafb7d608f..29da379691 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -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 {