#28348 [Opn->Bgs]: str_pad counts unicode characters as two
| From: | amt@php.net | Date: | Mon, 10 May 2004 13:54:51 +0000 |
| Subject: | #28348 [Opn->Bgs]: str_pad counts unicode characters as two | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-59466@lists.php.net to get a copy of this message | ||
ID: 28348
Updated by: amt@php.net
Reported By: shy at weblab dot pt
-Status: Open
+Status: Bogus
Bug Type: Output Control
PHP Version: 4.3.4
New Comment:
In general, PHP is not Unicode savvy. You should use
something like mb_strlen() to discover the length of
your string and do the math yourself to create the
correctly padded string. i.e.
str_repeat('.', max(0, 10 - mb_strlen('Nao')));
Previous Comments:
------------------------------------------------------------------------
[2004-05-10 13:19:50] shy at weblab dot pt
Description:
------------
In a utf-8 encoded page str_pad counts 8-bit characters
as two.
Reproduce code:
---------------
<?=str_pad('Nação',10,'.'),'Representante';?>
Expected result:
----------------
Nação.....Representante
Actual result:
--------------
Nação...Representante
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28348&edit=1