From f79fed628665905bc4cdf3be601a5dc8496f4555 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 16 Aug 2005 10:18:43 +0000 Subject: [PATCH] Unicode support --- ext/standard/md5.c | 14 ++- ext/standard/tests/strings/explode.phpt | 124 ++++++++++++++++++++++++ ext/standard/tests/strings/strcspn.phpt | 6 ++ ext/standard/tests/strings/strspn.phpt | 6 ++ ext/standard/tests/strings/strstr.phpt | 15 +++ 5 files changed, 163 insertions(+), 2 deletions(-) diff --git a/ext/standard/md5.c b/ext/standard/md5.c index 7242b40626..d8eb900eb5 100644 --- a/ext/standard/md5.c +++ b/ext/standard/md5.c @@ -61,7 +61,12 @@ PHP_NAMED_FUNCTION(php_if_md5) RETURN_STRINGL(digest, 16, 1); } else { make_digest(md5str, digest); - RETVAL_STRING(md5str, 1); + if (UG(unicode)) { + UChar *u_temp = zend_ascii_to_unicode(md5str, 33 ZEND_FILE_LINE_CC); + RETVAL_UNICODE(u_temp, 0); + } else { + RETVAL_STRING(md5str, 1); + } } } @@ -108,7 +113,12 @@ PHP_NAMED_FUNCTION(php_if_md5_file) RETURN_STRINGL(digest, 16, 1); } else { make_digest(md5str, digest); - RETVAL_STRING(md5str, 1); + if (UG(unicode)) { + UChar *u_temp = zend_ascii_to_unicode(md5str, 33 ZEND_FILE_LINE_CC); + RETVAL_UNICODE(u_temp, 0); + } else { + RETVAL_STRING(md5str, 1); + } } } /* }}} */ diff --git a/ext/standard/tests/strings/explode.phpt b/ext/standard/tests/strings/explode.phpt index 1198a09a97..35ab73a4ed 100644 --- a/ext/standard/tests/strings/explode.phpt +++ b/ext/standard/tests/strings/explode.phpt @@ -152,3 +152,127 @@ array(1) { [0]=> string(10) "a lazy dog" } +--UEXPECTF-- +26d4e18734cb2582df5055e2175223df +bool(false) +bool(false) +bool(false) +array(1) { + [0]=> + unicode(0) "" +} +array(2) { + [0]=> + unicode(0) "" + [1]=> + unicode(0) "" +} +array(1) { + [0]=> + unicode(0) "" +} +bool(false) +array(1) { + [0]=> + unicode(3) "acb" +} +array(1) { + [0]=> + unicode(11) "otherstring" +} +array(7) { + [0]=> + unicode(0) "" + [1]=> + unicode(0) "" + [2]=> + unicode(0) "" + [3]=> + unicode(0) "" + [4]=> + unicode(0) "" + [5]=> + unicode(0) "" + [6]=> + unicode(0) "" +} +array(1) { + [0]=> + unicode(60) "-=48=--=48=--=48=--=48=--=48=--=48=--=48=--=48=--=48=--=48=-" +} +array(21) { + [0]=> + unicode(1) "-" + [1]=> + unicode(2) "48" + [2]=> + unicode(2) "--" + [3]=> + unicode(2) "48" + [4]=> + unicode(2) "--" + [5]=> + unicode(2) "48" + [6]=> + unicode(2) "--" + [7]=> + unicode(2) "48" + [8]=> + unicode(2) "--" + [9]=> + unicode(2) "48" + [10]=> + unicode(2) "--" + [11]=> + unicode(2) "48" + [12]=> + unicode(2) "--" + [13]=> + unicode(2) "48" + [14]=> + unicode(2) "--" + [15]=> + unicode(2) "48" + [16]=> + unicode(2) "--" + [17]=> + unicode(2) "48" + [18]=> + unicode(2) "--" + [19]=> + unicode(2) "48" + [20]=> + unicode(1) "-" +} +array(3) { + [0]=> + unicode(10) "a lazy dog" + [1]=> + unicode(5) "jumps" + [2]=> + unicode(4) "over" +} +array(2) { + [0]=> + unicode(10) "a lazy dog" + [1]=> + unicode(5) "jumps" +} +array(1) { + [0]=> + unicode(10) "a lazy dog" +} +array(0) { +} +array(0) { +} +array(2) { + [0]=> + unicode(10) "a lazy dog" + [1]=> + unicode(11) "jumps::over" +} +array(1) { + [0]=> + unicode(10) "a lazy dog" +} diff --git a/ext/standard/tests/strings/strcspn.phpt b/ext/standard/tests/strings/strcspn.phpt index 88bcee5c19..8f8b1a4285 100644 --- a/ext/standard/tests/strings/strcspn.phpt +++ b/ext/standard/tests/strings/strcspn.phpt @@ -16,3 +16,9 @@ string(4) "1234" int(0) int(7) int(6) +--UEXPECT-- +unicode(25) "22222222aaaa bbb1111 cccc" +unicode(4) "1234" +int(0) +int(7) +int(6) diff --git a/ext/standard/tests/strings/strspn.phpt b/ext/standard/tests/strings/strspn.phpt index 9f498b84d6..6780e1d398 100644 --- a/ext/standard/tests/strings/strspn.phpt +++ b/ext/standard/tests/strings/strspn.phpt @@ -16,3 +16,9 @@ string(4) "1234" int(8) int(6) int(3) +--UEXPECT-- +unicode(25) "22222222aaaa bbb1111 cccc" +unicode(4) "1234" +int(8) +int(6) +int(3) diff --git a/ext/standard/tests/strings/strstr.phpt b/ext/standard/tests/strings/strstr.phpt index e18a41053e..85e832e69e 100644 --- a/ext/standard/tests/strings/strstr.phpt +++ b/ext/standard/tests/strings/strstr.phpt @@ -32,3 +32,18 @@ bool(false) string(32) "6ec19f52f0766c463f3bb240f4396913" string(7) " string" string(4) "test" +--UEXPECT-- +unicode(11) "test string" +unicode(6) "string" +unicode(6) "string" +unicode(8) "t string" +unicode(1) "g" +unicode(32) "7272696018bdeb2c9a3f8d01fc2a9273" +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +unicode(32) "6ec19f52f0766c463f3bb240f4396913" +unicode(7) " string" +unicode(4) "test" -- 2.50.1