xref: /PHP-8.1/ext/mbstring/tests/mb_strwidth.phpt (revision 39131219)
1--TEST--
2mb_strwidth()
3--EXTENSIONS--
4mbstring
5--FILE--
6<?php
7ini_set('include_path', __DIR__);
8include_once('common.inc');
9
10// EUC-JP
11$euc_jp  = pack('H*', '30313233a4b3a4cecab8bbfacef3a4cfc6fccbdcb8eca4c7a4b9a1a34555432d4a50a4f2bbc8a4c3a4c6a4a4a4dea4b9a1a3c6fccbdcb8eca4cfccccc5ddbdada4a4a1a3');
12// UTF-8
13$utf8    = '∮ E⋅da = Q';
14// UTF-16LE
15$utf16le = pack('H*', '1a043804400438043b043b04380446043004200069007300200043007900720069006c006c0069006300');
16// UTF-16BE
17$utf16be = pack('H*', '041a043804400438043b043b04380446043000200069007300200043007900720069006c006c00690063');
18// KOI8-R
19$koi8r   = pack('H*', 'ebc9d2c9ccccc9c3c120697320437972696c6c6963');
20
21print "1: " . mb_strwidth($euc_jp,  'EUC-JP')   . "\n";
22print "2: " . mb_strwidth($utf8,    'UTF-8')    . "\n";
23print "3: " . mb_strwidth($utf16le, 'UTF-16LE') . "\n";
24print "4: " . mb_strwidth($utf16be, 'UTF-16BE') . "\n";
25print "5: " . mb_strwidth($koi8r,   'KOI8-R')   . "\n";
26
27?>
28--EXPECT--
291: 68
302: 10
313: 21
324: 21
335: 21
34