andrei Wed Aug 17 13:39:07 2005 EDT
Modified files:
/php-src/ext/standard string.c
Log:
Fix bin2hex() to work on binary data and return strings of correct type.
http://cvs.php.net/diff.php/php-src/ext/standard/string.c?r1=1.462&r2=1.463&ty=u
Index: php-src/ext/standard/string.c
diff -u php-src/ext/standard/string.c:1.462 php-src/ext/standard/string.c:1.463
--- php-src/ext/standard/string.c:1.462 Wed Aug 17 13:33:19 2005
+++ php-src/ext/standard/string.c Wed Aug 17 13:39:04 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: string.c,v 1.462 2005/08/17 17:33:19 rolland Exp $ */
+/* $Id: string.c,v 1.463 2005/08/17 17:39:04 andrei Exp $ */
/* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
@@ -185,22 +185,28 @@
Converts the binary representation of data to hex */
PHP_FUNCTION(bin2hex)
{
- zval **data;
+ unsigned char *data;
+ int data_len;
char *result;
size_t newlen;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &data) ==
FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "y", &data,
&data_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(data);
- result = php_bin2hex(Z_STRVAL_PP(data), Z_STRLEN_PP(data), &newlen);
+ result = php_bin2hex(data, data_len, &newlen);
if (!result) {
RETURN_FALSE;
}
- RETURN_STRINGL(result, newlen, 0);
+ if (UG(unicode)) {
+ UChar *u_temp = zend_ascii_to_unicode(result, newlen+1
ZEND_FILE_LINE_CC);
+ efree(result);
+ RETVAL_UNICODEL(u_temp, newlen, 0);
+ } else {
+ RETURN_STRINGL(result, newlen, 0);
+ }
}
/* }}} */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php