1--TEST-- 2mb_stripos() 3--SKIPIF-- 4<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?> 5--FILE-- 6<?php 7// TODO: Add more encodings 8 9ini_set('include_path','.'); 10include_once('common.inc'); 11 12 13// Test string 14$euc_jp = '0123����ʸ��������ܸ�Ǥ���EUC-JP��ȤäƤ��ޤ���0123���ܸ�����ݽ�����'; 15 16$slen = mb_strlen($euc_jp, 'EUC-JP'); 17echo "String len: $slen\n"; 18 19// EUC-JP - With encoding parameter 20mb_internal_encoding('UTF-8') or print("mb_internal_encoding() failed\n"); 21 22echo "== POSITIVE OFFSET ==\n"; 23 24print mb_stripos($euc_jp, '���ܸ�', 0, 'EUC-JP') . "\n"; 25print mb_stripos($euc_jp, '0', 0, 'EUC-JP') . "\n"; 26print mb_stripos($euc_jp, 3, 0, 'EUC-JP') . "\n"; 27print mb_stripos($euc_jp, 0, 0, 'EUC-JP') . "\n"; 28print mb_stripos($euc_jp, '���ܸ�', 15, 'EUC-JP') . "\n"; 29print mb_stripos($euc_jp, '0', 15, 'EUC-JP') . "\n"; 30print mb_stripos($euc_jp, 3, 15, 'EUC-JP') . "\n"; 31print mb_stripos($euc_jp, 0, 15, 'EUC-JP') . "\n"; 32 33 34// Negative offset 35echo "== NEGATIVE OFFSET ==\n"; 36 37print mb_stripos($euc_jp, '���ܸ�', -15, 'EUC-JP') . "\n"; 38print mb_stripos($euc_jp, '0', -15, 'EUC-JP') . "\n"; 39print mb_stripos($euc_jp, 3, -15, 'EUC-JP') . "\n"; 40print mb_stripos($euc_jp, 0, -15, 'EUC-JP') . "\n"; 41print mb_stripos($euc_jp, 0, -43, 'EUC-JP') . "\n"; 42 43 44// Out of range - should return false 45print ("== OUT OF RANGE ==\n"); 46 47$r = mb_stripos($euc_jp, '���ܸ�', 40, 'EUC-JP'); 48($r === FALSE) ? print "OK_OUT_RANGE\n" : print "NG_OUT_RANGE\n"; 49$r = mb_stripos($euc_jp, '0', 40, 'EUC-JP'); 50($r === FALSE) ? print "OK_OUT_RANGE\n" : print "NG_OUT_RANGE\n"; 51$r = mb_stripos($euc_jp, 3, 40, 'EUC-JP'); 52($r === FALSE) ? print "OK_OUT_RANGE\n" : print "NG_OUT_RANGE\n"; 53$r = mb_stripos($euc_jp, 0, 40, 'EUC-JP'); 54($r === FALSE) ? print "OK_OUT_RANGE\n" : print "NG_OUT_RANGE\n"; 55$r = mb_stripos($euc_jp, '���ܸ�', -3, 'EUC-JP'); 56($r === FALSE) ? print "OK_OUT_RANGE\n" : print "NG_OUT_RANGE\n"; 57$r = mb_stripos($euc_jp, '0', -3, 'EUC-JP'); 58($r === FALSE) ? print "OK_OUT_RANGE\n" : print "NG_OUT_RANGE\n"; 59$r = mb_stripos($euc_jp, 3, -3, 'EUC-JP'); 60($r === FALSE) ? print "OK_OUT_RANGE\n" : print "NG_OUT_RANGE\n"; 61$r = mb_stripos($euc_jp, 0, -3, 'EUC-JP'); 62($r === FALSE) ? print "OK_OUT_RANGE\n" : print "NG_OUT_RANGE\n"; 63 64 65// Non-existent 66echo "== NON-EXISTENT ==\n"; 67 68$r = mb_stripos($euc_jp, '�ڹ��', 0, 'EUC-JP'); 69($r === FALSE) ? print "OK_STR\n" : print "NG_STR\n"; 70$r = mb_stripos($euc_jp, "\n", 0, 'EUC-JP'); 71($r === FALSE) ? print "OK_NEWLINE\n" : print "NG_NEWLINE\n"; 72 73 74// EUC-JP - No encoding parameter 75echo "== NO ENCODING PARAMETER ==\n"; 76 77mb_internal_encoding('EUC-JP') or print("mb_internal_encoding() failed\n"); 78 79print mb_stripos($euc_jp, '���ܸ�', 0) . "\n"; 80print mb_stripos($euc_jp, '0', 0) . "\n"; 81print mb_stripos($euc_jp, 3, 0) . "\n"; 82print mb_stripos($euc_jp, 0, 0) . "\n"; 83 84$r = mb_stripos($euc_jp, '�ڹ��', 0); 85($r === FALSE) ? print "OK_STR\n" : print "NG_STR\n"; 86$r = mb_stripos($euc_jp, "\n", 0); 87($r === FALSE) ? print "OK_NEWLINE\n" : print "NG_NEWLINE\n"; 88 89// EUC-JP - No offset and encoding parameter 90echo "== NO OFFSET AND ENCODING PARAMETER ==\n"; 91 92mb_internal_encoding('EUC-JP') or print("mb_internal_encoding() failed\n"); 93 94print mb_stripos($euc_jp, '���ܸ�') . "\n"; 95print mb_stripos($euc_jp, '0') . "\n"; 96print mb_stripos($euc_jp, 3) . "\n"; 97print mb_stripos($euc_jp, 0) . "\n"; 98 99$r = mb_stripos($euc_jp, '�ڹ��'); 100($r === FALSE) ? print "OK_STR\n" : print "NG_STR\n"; 101$r = mb_stripos($euc_jp, "\n"); 102($r === FALSE) ? print "OK_NEWLINE\n" : print "NG_NEWLINE\n"; 103 104?> 105--EXPECT-- 106String len: 43 107== POSITIVE OFFSET == 10810 1090 1103 1110 11234 11330 11433 11530 116== NEGATIVE OFFSET == 11734 11830 11933 12030 1210 122== OUT OF RANGE == 123OK_OUT_RANGE 124OK_OUT_RANGE 125OK_OUT_RANGE 126OK_OUT_RANGE 127OK_OUT_RANGE 128OK_OUT_RANGE 129OK_OUT_RANGE 130OK_OUT_RANGE 131== NON-EXISTENT == 132OK_STR 133OK_NEWLINE 134== NO ENCODING PARAMETER == 13510 1360 1373 1380 139OK_STR 140OK_NEWLINE 141== NO OFFSET AND ENCODING PARAMETER == 14210 1430 1443 1450 146OK_STR 147OK_NEWLINE 148