Annotation of embedaddon/php/ext/mbstring/tests/mb_substr.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: mb_substr()
3: --SKIPIF--
4: <?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
5: --INI--
6: output_handler=
7: mbstring.func_overload=0
8: --FILE--
9: <?php
10: // TODO: Add more encodings
11: ini_set('include_path','.');
12: include_once('common.inc');
13:
14: // EUC-JP
15: $euc_jp = b'0123この文字列は日本語です。EUC-JPを使っています。日本語は面倒臭い。';
16:
17: print "1: ". bin2hex(mb_substr($euc_jp, 10, 10,'EUC-JP')) . "\n";
18: print "2: ". bin2hex(mb_substr($euc_jp, 0, 100,'EUC-JP')) . "\n";
19:
20: $str = mb_substr($euc_jp, 100, 10,'EUC-JP');
21: // Note: returns last character
22: ($str === "") ? print "3 OK\n" : print "NG: ".bin2hex($str)."\n";
23:
24: $str = mb_substr($euc_jp, -100, 10,'EUC-JP');
25: ($str !== "") ? print "4 OK: ".bin2hex($str)."\n" : print "NG: ".bin2hex($str)."\n";
26:
27: ?>
28:
29: --EXPECT--
30: 1: c6fccbdcb8eca4c7a4b9a1a34555432d
31: 2: 30313233a4b3a4cecab8bbfacef3a4cfc6fccbdcb8eca4c7a4b9a1a34555432d4a50a4f2bbc8a4c3a4c6a4a4a4dea4b9a1a3c6fccbdcb8eca4cfccccc5ddbdada4a4a1a3
32: 3 OK
33: 4 OK: 30313233a4b3a4cecab8bbfacef3a4cf
34:
35:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>