1--TEST--
2mb_strimwidth()
3--EXTENSIONS--
4mbstring
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
24try {
25    var_dump(mb_strimwidth($euc_jp, 0, -100,'...','EUC-JP'));
26} catch (\ValueError $e) {
27    echo $e->getMessage() . \PHP_EOL;
28}
29try {
30    var_dump(mb_strimwidth($euc_jp, 100, 10,'...','EUC-JP'));
31} catch (\ValueError $e) {
32    echo $e->getMessage() . \PHP_EOL;
33}
34try {
35    var_dump(mb_strimwidth($euc_jp, -100, 10,'...','EUC-JP'));
36} catch (\ValueError $e) {
37    echo $e->getMessage() . \PHP_EOL;
38}
39try {
40    var_dump(mb_strimwidth($euc_jp, -10, -12,'...','EUC-JP'));
41} catch (\ValueError $e) {
42    echo $e->getMessage() . \PHP_EOL;
43}
44
45?>
46--EXPECT--
47String width: 68
481: 0123����ʸ��...
492: 0123����ʸ��������ܸ�Ǥ���EUC-JP��ȤäƤ��ޤ������ܸ�����ݽ�����
503: ��EUC-JP��ȤäƤ��ޤ������ܸ�����ݽ�����
514: ��
525: ��
536: ��
547: ��
55mb_strimwidth(): Argument #3 ($width) is out of range
56mb_strimwidth(): Argument #2 ($start) is out of range
57mb_strimwidth(): Argument #2 ($start) is out of range
58mb_strimwidth(): Argument #3 ($width) is out of range
59