Lines Matching refs:width
24 function testStrimwidthWithMarker($string, $trimmark, $start, $width, $encoding) {
25 $result = mb_strimwidth($string, $start, $width, $trimmark, $encoding);
26 print "start=$start width=$width result=[";
29 print " width=" . mb_strwidth($result, $encoding) . "\n";
32 function testStrimwidth($string, $start, $width, $encoding) {
33 …testStrimwidthWithMarker($string, mb_convert_encoding('...', $encoding, 'ASCII'), $start, $width, …
42 print "String width: " . mb_strwidth($utf16le, 'UTF-16LE') . "\n";
49 // OK, now the string will just barely fit in the allowed width...
58 // What if we expect an output width of zero?
59 // (It will still output the trim marker, pushing the width beyond the stipulated 'maximum')
62 // Or output width of one?
66 // OK, let's count back 3 characters from the end of the string, then allow a width of 5
70 // Let's also try a negative width
71 // We'll count back 4 characters, then allow a width of ((4 * 2) - 2) = 6
73 // will have to be added, and will consume a width of 3
74 // We also suppress the deprecation for negative width as of PHP 8.3
83 print "String width: " . mb_strwidth($euc_jp, 'EUC-JP') . "\n";
87 // Cut down to a width of 15, which is 10 characters in this case.
91 // With max width of 100, trim marker will not be added
97 // Count 30 characters back from end of string, then limit to width of 5
98 // Since width of trim marker is 3, this will only get a single char from string
105 // Skip 15 characters, which leaves a total width of 42. Then trim string down
106 // to 5 less than that, which is a width of 37.
107 // We also suppress the deprecation for negative width as of PHP 8.3
110 // Take the last 30 characters, which have a width of 54. Trim string down to
112 // We also suppress the deprecation for negative width as of PHP 8.3
119 // Take the last 10 characters, which have a width of 20. Trim string down to
120 // 12 less than that, which is a width of 8.
121 // We also suppress the deprecation for negative width as of PHP 8.3
125 // We also suppress the deprecation for negative width as of PHP 8.3
141 // We also suppress the deprecation for negative width as of PHP 8.3
151 for ($width = -5; $width <= 5; $width++) {
152 if ($from < 0 && $width < 0 && $width < $from) {
157 @mb_strimwidth($str, $from, $width, '...', 'ASCII');
167 $result = @mb_strimwidth($str, $from, $width, '...', 'ASCII');
169 if ($from < 0 && $width < 0 && ($width - $from) <= 3) {
171 … been trim marker. string=" . $str . " result=" . $result . " from=" . $from . " width=" . $width);
175 if ($width < 0 || $width > 3) {
177 …he expected point! string=" . $str . " result=" . $result . " from=" . $from . " width=" . $width);
180 if ($width >= 3 && ($from >= 0 || $width <= abs($from))) {
181 if (mb_strwidth($result, 'ASCII') !== $width)
182 …nt from requested. string=" . $str . " result=" . $result . " from=" . $from . " width=" . $width);
185 if ($width < 0) {
188 if (mb_substr($result, -4, 1, 'ASCII') !== mb_substr($str, $width-4, 1, 'ASCII'))
189 …he expected point. string=" . $str . " result=" . $result . " from=" . $from . " width=" . $width);
196 // through when requested width=0
211 // it was wider than requested width, if the trim marker string was wider than
220 // combined with negative 'width' argument correctly when portion being skipped
222 // We also suppress the deprecation for negative width as of PHP 8.3
229 String width: 14
233 start=0 width=100 result=[3100 3200 3300 6100 6200 6300 226f 575b 4b30 6a30] length=10 width=14
234 start=0 width=14 result=[3100 3200 3300 6100 6200 6300 226f 575b 4b30 6a30] length=10 width=14
235 start=0 width=13 result=[3100 3200 3300 6100 6200 6300 226f 575b 2e00 2e00 2e00] length=11 width=13
236 start=0 width=12 result=[3100 3200 3300 6100 6200 6300 226f 2e00 2e00 2e00] length=10 width=11
237 start=0 width=0 result=[2e00 2e00 2e00] length=3 width=3
238 start=0 width=1 result=[2e00 2e00 2e00] length=3 width=3
239 start=-3 width=5 result=[575b 2e00 2e00 2e00] length=4 width=5
240 start=-4 width=-2 result=[226f 2e00 2e00 2e00] length=4 width=5
244 String width: 68
248 start=0 width=15 result=[30 31 32 33 a4b3 a4ce cab8 bbfa 2e 2e 2e] length=11 width=15
249 …width=100 result=[30 31 32 33 a4b3 a4ce cab8 bbfa cef3 a4cf c6fc cbdc b8ec a4c7 a4b9 a1a3 45 55 43…
250 …t=15 width=100 result=[a1a3 45 55 43 2d 4a 50 a4f2 bbc8 a4c3 a4c6 a4a4 a4de a4b9 a1a3 c6fc cbdc b8…
251 start=-30 width=5 result=[a4cf 2e 2e 2e] length=4 width=5
252 start=9 width=5 result=[a4cf 2e 2e 2e] length=4 width=5
253 start=15 width=-5 result=[a1a3 45 55 43 2d 4a 50 a4f2 bbc8 a4c3 a4c6 a4a4 a4de a4b9 a1a3 c6fc cbdc …
254 start=-30 width=-25 result=[a4cf c6fc cbdc b8ec a4c7 a4b9 a1a3 45 55 43 2d 4a 50 a4f2 bbc8 a4c3 2e …
255 start=39 width=10 result=[] length=0 width=0
256 start=-10 width=-12 result=[a1a3 c6fc 2e 2e 2e] length=5 width=7
257 mb_strimwidth(): Argument #3 ($width) is out of range
260 mb_strimwidth(): Argument #3 ($width) is out of range
263 start=1 width=0 result=[2e 2e 2e] length=3 width=3
264 …width=255 result=[61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61…
265 start=0 width=10 result=[3f 3f 3f] length=3 width=3
266 start=0 width=10 result=[61 62 63 64 65 66 67 80 80 80] length=10 width=10
267 start=0 width=1 result=[61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70] length=16 width=16
268 start=-3 width=10 result=[61 62 63] length=3 width=3
269 start=3 width=-1 result=[61 62 2e 2e 2e] length=5 width=5