Req #81244 [Opn->Wfx]: make *printf() function Unicode-aware
| From: | nikic@php.net | Date: | Mon, 12 Jul 2021 13:31:40 +0000 |
| Subject: | Req #81244 [Opn->Wfx]: make *printf() function Unicode-aware | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-234972@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81244&edit=1
ID: 81244
Updated by: nikic@php.net
Reported by: flightvision at googlemail dot com
Summary: make *printf() function Unicode-aware
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: *Unicode Issues
PHP Version: 8.0.8
Block user comment: N
Private report: N
New Comment:
printf() widths are in terms of bytes, and this isn't going to change. Please use mb_substr()
or grapheme_substr() to truncate a string to a certain number of characters, depending on which
notion of "character" you wish to use (I would recommend extended grapheme clusters, if
you don't want to "truncate" away combining characters etc).
Previous Comments:
------------------------------------------------------------------------
[2021-07-11 10:21:11] flightvision at googlemail dot com
Description:
------------
The *printf() functions are having problems if strings contain non-ASCII characters.
Test script:
---------------
echo sprintf('%3.3s', 'ö12345');
echo sprintf('%3.3s', '12ö345');
Expected result:
----------------
ö12
12ö
Actual result:
--------------
ö1
12�
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81244&edit=1