Annotation of embedaddon/php/ext/mbstring/tests/mb_strstr_variation6.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test mb_strstr() function : variation - case sensitivity
! 3: --SKIPIF--
! 4: <?php
! 5: extension_loaded('mbstring') or die('skip');
! 6: function_exists('mb_strstr') or die("skip mb_strstr() is not available in this build");
! 7: ?>
! 8: --FILE--
! 9: <?php
! 10: /* Prototype : string mb_strstr(string haystack, string needle[, bool part[, string encoding]])
! 11: * Description: Finds first occurrence of a string within another
! 12: * Source code: ext/mbstring/mbstring.c
! 13: * Alias to functions:
! 14: */
! 15:
! 16: echo "*** Testing mb_strstr() : variation ***\n";
! 17:
! 18: mb_internal_encoding('UTF-8');
! 19:
! 20: //ascii
! 21: $string_ascii = b'abcdef';
! 22: $needle_ascii_upper = b"BCD";
! 23: $needle_ascii_mixed = b"bCd";
! 24: $needle_ascii_lower = b"bcd";
! 25:
! 26: //Greek string in lower case UTF-8
! 27: $string_mb = base64_decode('zrHOss6zzrTOtc62zrfOuM65zrrOu868zr3Ovs6/z4DPgc+Dz4TPhc+Gz4fPiM+J');
! 28: $needle_mb_upper = base64_decode('zpzOnc6ezp8=');
! 29: $needle_mb_lower = base64_decode('zrzOvc6+zr8=');
! 30: $needle_mb_mixed = base64_decode('zpzOnc6+zr8=');
! 31:
! 32: echo "-- Ascii data --\n";
! 33: // needle should be found
! 34: var_dump(bin2hex(mb_strstr($string_ascii, $needle_ascii_lower)));
! 35: // no needle should be found
! 36: var_dump(mb_strstr($string_ascii, $needle_ascii_upper));
! 37: var_dump(mb_strstr($string_ascii, $needle_ascii_mixed));
! 38:
! 39: echo "-- mb data in utf-8 --\n";
! 40: // needle should be found
! 41: $res = mb_strstr($string_mb, $needle_mb_lower, false);
! 42: if ($res !== false) {
! 43: var_dump(bin2hex($res));
! 44: }
! 45: else {
! 46: echo "nothing found!\n";
! 47: }
! 48: // no needle should be found
! 49: var_dump(mb_strstr($string_mb, $needle_mb_upper));
! 50: var_dump(mb_strstr($string_mb, $needle_mb_mixed));
! 51:
! 52:
! 53: ?>
! 54: ===DONE===
! 55: --EXPECT--
! 56: *** Testing mb_strstr() : variation ***
! 57: -- Ascii data --
! 58: string(10) "6263646566"
! 59: bool(false)
! 60: bool(false)
! 61: -- mb data in utf-8 --
! 62: string(52) "cebccebdcebecebfcf80cf81cf83cf84cf85cf86cf87cf88cf89"
! 63: bool(false)
! 64: bool(false)
! 65: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>