dmitry Tue Aug 16 05:11:00 2005 EDT Modified files: /php-src/ext/standard image.c /php-src/ext/standard/tests/image bug13213.phpt getimagesize.phpt getimagesize_246x247.phpt getimagesize_384x385.phpt getimagesize_swc.phpt image_type_to_mime_type.phpt Log: Unicode support
http://cvs.php.net/diff.php/php-src/ext/standard/image.c?r1=1.114&r2=1.115&ty=u Index: php-src/ext/standard/image.c diff -u php-src/ext/standard/image.c:1.114 php-src/ext/standard/image.c:1.115 --- php-src/ext/standard/image.c:1.114 Wed Aug 3 10:08:05 2005 +++ php-src/ext/standard/image.c Tue Aug 16 05:11:00 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: image.c,v 1.114 2005/08/03 14:08:05 sniper Exp $ */ +/* $Id: image.c,v 1.115 2005/08/16 09:11:00 dmitry Exp $ */ #include "php.h" #include <stdio.h> @@ -1120,13 +1120,20 @@ { zval **p_image_type; int arg_c = ZEND_NUM_ARGS(); + char *temp; if ((arg_c!=1) || zend_get_parameters_ex(arg_c, &p_image_type) == FAILURE) { RETVAL_FALSE; WRONG_PARAM_COUNT; } convert_to_long_ex(p_image_type); - ZVAL_STRING(return_value, (char*)php_image_type_to_mime_type(Z_LVAL_PP(p_image_type)), 1); + temp = (char*)php_image_type_to_mime_type(Z_LVAL_PP(p_image_type)); + if (UG(unicode)) { + UChar *u_temp = zend_ascii_to_unicode(temp, strlen(temp)+1 ZEND_FILE_LINE_CC); + ZVAL_UNICODE(return_value, u_temp, 0); + } else { + ZVAL_STRING(return_value, temp, 1); + } } /* }}} */ @@ -1136,6 +1143,7 @@ { long image_type; zend_bool inc_dot=1; + char *temp = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|b", &image_type, &inc_dot) == FAILURE) { RETURN_FALSE; @@ -1143,30 +1151,38 @@ switch (image_type) { case IMAGE_FILETYPE_GIF: - RETURN_STRING(".gif" + !inc_dot, 1); + temp = ".gif"; case IMAGE_FILETYPE_JPEG: - RETURN_STRING(".jpeg" + !inc_dot, 1); + temp = ".jpeg"; case IMAGE_FILETYPE_PNG: - RETURN_STRING(".png" + !inc_dot, 1); + temp = ".png"; case IMAGE_FILETYPE_SWF: case IMAGE_FILETYPE_SWC: - RETURN_STRING(".swf" + !inc_dot, 1); + temp = ".swf"; case IMAGE_FILETYPE_PSD: - RETURN_STRING(".psd" + !inc_dot, 1); + temp = ".psd"; case IMAGE_FILETYPE_BMP: case IMAGE_FILETYPE_WBMP: - RETURN_STRING(".bmp" + !inc_dot, 1); + temp = ".bmp"; case IMAGE_FILETYPE_TIFF_II: case IMAGE_FILETYPE_TIFF_MM: - RETURN_STRING(".tiff" + !inc_dot, 1); + temp = ".tiff"; case IMAGE_FILETYPE_IFF: - RETURN_STRING(".iff" + !inc_dot, 1); + temp = ".iff"; case IMAGE_FILETYPE_JPC: - RETURN_STRING(".jpc" + !inc_dot, 1); + temp = ".jpc"; case IMAGE_FILETYPE_JP2: - RETURN_STRING(".jp2" + !inc_dot, 1); + temp = ".jp2"; case IMAGE_FILETYPE_XBM: - RETURN_STRING(".xbm" + !inc_dot, 1); + temp = ".xbm"; + } + if (temp) { + if (UG(unicode)) { + UChar *u_temp = zend_ascii_to_unicode(temp + !inc_dot, strlen(temp)+inc_dot ZEND_FILE_LINE_CC); + RETURN_UNICODE(u_temp, 0); + } else { + RETURN_STRING(temp + !inc_dot, 1); + } } RETURN_FALSE; @@ -1357,7 +1373,13 @@ add_index_long(return_value, 1, result->height); add_index_long(return_value, 2, itype); spprintf(&temp, 0, "width=\"%d\" height=\"%d\"", result->width, result->height); - add_index_string(return_value, 3, temp, 0); + if (UG(unicode)) { + UChar *u_temp = zend_ascii_to_unicode(temp, strlen(temp)+1 ZEND_FILE_LINE_CC); + add_index_unicode(return_value, 3, u_temp, 0); + efree(temp); + } else { + add_index_string(return_value, 3, temp, 0); + } if (result->bits != 0) { add_assoc_long(return_value, "bits", result->bits); @@ -1365,7 +1387,13 @@ if (result->channels != 0) { add_assoc_long(return_value, "channels", result->channels); } - add_assoc_string(return_value, "mime", (char*)php_image_type_to_mime_type(itype), 1); + temp = (char*)php_image_type_to_mime_type(itype); + if (UG(unicode)) { + UChar *u_temp = zend_ascii_to_unicode(temp, strlen(temp)+1 ZEND_FILE_LINE_CC); + add_assoc_unicode(return_value, "mime", u_temp, 0); + } else { + add_assoc_string(return_value, "mime", temp, 1); + } efree(result); } else { RETURN_FALSE; http://cvs.php.net/diff.php/php-src/ext/standard/tests/image/bug13213.phpt?r1=1.2&r2=1.3&ty=u Index: php-src/ext/standard/tests/image/bug13213.phpt diff -u php-src/ext/standard/tests/image/bug13213.phpt:1.2 php-src/ext/standard/tests/image/bug13213.phpt:1.3 --- php-src/ext/standard/tests/image/bug13213.phpt:1.2 Thu Jan 23 14:07:24 2003 +++ php-src/ext/standard/tests/image/bug13213.phpt Tue Aug 16 05:11:00 2005 @@ -21,3 +21,20 @@ ["mime"]=> string(10) "image/jpeg" } +--UEXPECT-- +array(7) { + [0]=> + int(1) + [1]=> + int(1) + [2]=> + int(2) + [3]=> + unicode(20) "width="1" height="1"" + [u"bits"]=> + int(8) + [u"channels"]=> + int(3) + [u"mime"]=> + unicode(10) "image/jpeg" +} http://cvs.php.net/diff.php/php-src/ext/standard/tests/image/getimagesize.phpt?r1=1.6&r2=1.7&ty=u Index: php-src/ext/standard/tests/image/getimagesize.phpt diff -u php-src/ext/standard/tests/image/getimagesize.phpt:1.6 php-src/ext/standard/tests/image/getimagesize.phpt:1.7 --- php-src/ext/standard/tests/image/getimagesize.phpt:1.6 Fri Jan 17 18:57:43 2003 +++ php-src/ext/standard/tests/image/getimagesize.phpt Tue Aug 16 05:11:00 2005 @@ -194,3 +194,175 @@ string(10) "image/tiff" } } +--UEXPECT-- +array(11) { + [u"test1pix.bmp"]=> + array(6) { + [0]=> + int(1) + [1]=> + int(1) + [2]=> + int(6) + [3]=> + unicode(20) "width="1" height="1"" + [u"bits"]=> + int(24) + [u"mime"]=> + unicode(9) "image/bmp" + } + [u"test1pix.jp2"]=> + array(7) { + [0]=> + int(1) + [1]=> + int(1) + [2]=> + int(10) + [3]=> + unicode(20) "width="1" height="1"" + [u"bits"]=> + int(8) + [u"channels"]=> + int(3) + [u"mime"]=> + unicode(9) "image/jp2" + } + [u"test1pix.jpc"]=> + array(7) { + [0]=> + int(1) + [1]=> + int(1) + [2]=> + int(9) + [3]=> + unicode(20) "width="1" height="1"" + [u"bits"]=> + int(8) + [u"channels"]=> + int(3) + [u"mime"]=> + unicode(24) "application/octet-stream" + } + [u"test1pix.jpg"]=> + array(7) { + [0]=> + int(1) + [1]=> + int(1) + [2]=> + int(2) + [3]=> + unicode(20) "width="1" height="1"" + [u"bits"]=> + int(8) + [u"channels"]=> + int(3) + [u"mime"]=> + unicode(10) "image/jpeg" + } + [u"test2pix.gif"]=> + array(7) { + [0]=> + int(2) + [1]=> + int(1) + [2]=> + int(1) + [3]=> + unicode(20) "width="2" height="1"" + [u"bits"]=> + int(1) + [u"channels"]=> + int(3) + [u"mime"]=> + unicode(9) "image/gif" + } + [u"test4pix.gif"]=> + array(7) { + [0]=> + int(4) + [1]=> + int(1) + [2]=> + int(1) + [3]=> + unicode(20) "width="4" height="1"" + [u"bits"]=> + int(2) + [u"channels"]=> + int(3) + [u"mime"]=> + unicode(9) "image/gif" + } + [u"test4pix.iff"]=> + array(6) { + [0]=> + int(4) + [1]=> + int(1) + [2]=> + int(14) + [3]=> + unicode(20) "width="4" height="1"" + [u"bits"]=> + int(4) + [u"mime"]=> + unicode(9) "image/iff" + } + [u"test4pix.png"]=> + array(6) { + [0]=> + int(4) + [1]=> + int(1) + [2]=> + int(3) + [3]=> + unicode(20) "width="4" height="1"" + [u"bits"]=> + int(4) + [u"mime"]=> + unicode(9) "image/png" + } + [u"test4pix.psd"]=> + array(5) { + [0]=> + int(4) + [1]=> + int(1) + [2]=> + int(5) + [3]=> + unicode(20) "width="4" height="1"" + [u"mime"]=> + unicode(9) "image/psd" + } + [u"test4pix.swf"]=> + array(5) { + [0]=> + int(550) + [1]=> + int(400) + [2]=> + int(4) + [3]=> + unicode(24) "width="550" height="400"" + [u"mime"]=> + unicode(29) "application/x-shockwave-flash" + } + [u"test4pix.tif"]=> + array(5) { + [0]=> + int(4) + [1]=> + int(1) + [2]=> + int(7) + [3]=> + unicode(20) "width="4" height="1"" + [u"mime"]=> + unicode(10) "image/tiff" + } +} http://cvs.php.net/diff.php/php-src/ext/standard/tests/image/getimagesize_246x247.phpt?r1=1.1&r2=1.2&ty=u Index: php-src/ext/standard/tests/image/getimagesize_246x247.phpt diff -u php-src/ext/standard/tests/image/getimagesize_246x247.phpt:1.1 php-src/ext/standard/tests/image/getimagesize_246x247.phpt:1.2 --- php-src/ext/standard/tests/image/getimagesize_246x247.phpt:1.1 Mon Nov 18 11:51:02 2002 +++ php-src/ext/standard/tests/image/getimagesize_246x247.phpt Tue Aug 16 05:11:00 2005 @@ -40,3 +40,21 @@ string(9) "image/png" } } +--UEXPECT-- +array(1) { + [u"246x247.png"]=> + array(6) { + [0]=> + int(246) + [1]=> + int(247) + [2]=> + int(3) + [3]=> + unicode(24) "width="246" height="247"" + [u"bits"]=> + int(4) + [u"mime"]=> + unicode(9) "image/png" + } +} http://cvs.php.net/diff.php/php-src/ext/standard/tests/image/getimagesize_384x385.phpt?r1=1.1&r2=1.2&ty=u Index: php-src/ext/standard/tests/image/getimagesize_384x385.phpt diff -u php-src/ext/standard/tests/image/getimagesize_384x385.phpt:1.1 php-src/ext/standard/tests/image/getimagesize_384x385.phpt:1.2 --- php-src/ext/standard/tests/image/getimagesize_384x385.phpt:1.1 Mon Nov 18 11:51:02 2002 +++ php-src/ext/standard/tests/image/getimagesize_384x385.phpt Tue Aug 16 05:11:00 2005 @@ -40,3 +40,21 @@ string(9) "image/png" } } +--UEXPECT-- +array(1) { + [u"384x385.png"]=> + array(6) { + [0]=> + int(384) + [1]=> + int(385) + [2]=> + int(3) + [3]=> + unicode(24) "width="384" height="385"" + [u"bits"]=> + int(1) + [u"mime"]=> + unicode(9) "image/png" + } +} http://cvs.php.net/diff.php/php-src/ext/standard/tests/image/getimagesize_swc.phpt?r1=1.2&r2=1.3&ty=u Index: php-src/ext/standard/tests/image/getimagesize_swc.phpt diff -u php-src/ext/standard/tests/image/getimagesize_swc.phpt:1.2 php-src/ext/standard/tests/image/getimagesize_swc.phpt:1.3 --- php-src/ext/standard/tests/image/getimagesize_swc.phpt:1.2 Thu Dec 16 07:34:31 2004 +++ php-src/ext/standard/tests/image/getimagesize_swc.phpt Tue Aug 16 05:11:00 2005 @@ -23,3 +23,16 @@ ["mime"]=> string(29) "application/x-shockwave-flash" } +--UEXPECT-- +array(5) { + [0]=> + int(550) + [1]=> + int(400) + [2]=> + int(13) + [3]=> + unicode(24) "width="550" height="400"" + [u"mime"]=> + unicode(29) "application/x-shockwave-flash" +} http://cvs.php.net/diff.php/php-src/ext/standard/tests/image/image_type_to_mime_type.phpt?r1=1.5&r2=1.6&ty=u Index: php-src/ext/standard/tests/image/image_type_to_mime_type.phpt diff -u php-src/ext/standard/tests/image/image_type_to_mime_type.phpt:1.5 php-src/ext/standard/tests/image/image_type_to_mime_type.phpt:1.6 --- php-src/ext/standard/tests/image/image_type_to_mime_type.phpt:1.5 Fri Jan 17 13:51:30 2003 +++ php-src/ext/standard/tests/image/image_type_to_mime_type.phpt Tue Aug 16 05:11:00 2005 @@ -48,4 +48,29 @@ string(29) "application/x-shockwave-flash" ["test4pix.tif"]=> string(10) "image/tiff" +} +--UEXPECT-- +array(11) { + [u"test1pix.bmp"]=> + unicode(9) "image/bmp" + [u"test1pix.jp2"]=> + unicode(9) "image/jp2" + [u"test1pix.jpc"]=> + unicode(24) "application/octet-stream" + [u"test1pix.jpg"]=> + unicode(10) "image/jpeg" + [u"test2pix.gif"]=> + unicode(9) "image/gif" + [u"test4pix.gif"]=> + unicode(9) "image/gif" + [u"test4pix.iff"]=> + unicode(9) "image/iff" + [u"test4pix.png"]=> + unicode(9) "image/png" + [u"test4pix.psd"]=> + unicode(9) "image/psd" + [u"test4pix.swf"]=> + unicode(29) "application/x-shockwave-flash" + [u"test4pix.tif"]=> + unicode(10) "image/tiff" } \ No newline at end of file
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php