|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-05-10 13:19 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 22:00:01 2025 UTC |
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')));