1--TEST--
2mb_strimwidth()
3--SKIPIF--
4<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
5--INI--
6output_handler=
7--FILE--
8<?php
9// TODO: Add more encoding
10
11// EUC-JP
12$euc_jp = '0123����ʸ��������ܸ�Ǥ���EUC-JP��ȤäƤ��ޤ������ܸ�����ݽ�����';
13
14print "String width: ".mb_strwidth($euc_jp,'EUC-JP')."\n";
15
16print  "1: ". mb_strimwidth($euc_jp,  0, 15,'...','EUC-JP') . "\n";
17print  "2: ". mb_strimwidth($euc_jp,  0, 100,'...','EUC-JP') . "\n";
18print  "3: ". mb_strimwidth($euc_jp, 15, 100,'...','EUC-JP') . "\n";
19print  "4: ". mb_strimwidth($euc_jp, -30, 5,'...','EUC-JP') . "\n";
20print  "5: ". mb_strimwidth($euc_jp, 38, 5,'...','EUC-JP') . "\n";
21print  "6: ". mb_strimwidth($euc_jp, 38, -25,'...','EUC-JP') . "\n";
22print  "7: ". mb_strimwidth($euc_jp, -30, -25,'...','EUC-JP') . "\n";
23
24$str = mb_strimwidth($euc_jp, 0, -100,'...','EUC-JP');
25($str === FALSE) ? print "10 OK\n" : print "NG: $str\n";
26
27$str = mb_strimwidth($euc_jp, 100, 10,'...','EUC-JP');
28($str === FALSE) ? print "11 OK\n" : print "NG: $str\n";
29
30$str = mb_strimwidth($euc_jp, -100, 10,'...','EUC-JP');
31($str === FALSE) ? print "12 OK\n" : print "NG: $str\n";
32
33$str = mb_strimwidth($euc_jp, -10, -12,'...','EUC-JP');
34($str === FALSE) ? print "13 OK\n" : print "NG: $str\n";
35
36?>
37--EXPECTF--
38String width: 68
391: 0123����ʸ��...
402: 0123����ʸ��������ܸ�Ǥ���EUC-JP��ȤäƤ��ޤ������ܸ�����ݽ�����
413: ��EUC-JP��ȤäƤ��ޤ������ܸ�����ݽ�����
424: ��
435: ��
446: ��
457: ��
46
47Warning: mb_strimwidth(): Width is out of range in %s on line %d
4810 OK
49
50Warning: mb_strimwidth(): Start position is out of range in %s on line %d
5111 OK
52
53Warning: mb_strimwidth(): Start position is out of range in %s on line %d
5412 OK
55
56Warning: mb_strimwidth(): Width is out of range in %s on line %d
5713 OK
58