Bug #67276 [Com]: mb_strwidth count combining chars

From: Date: Mon, 16 Aug 2021 15:23:14 +0000
Subject: Bug #67276 [Com]: mb_strwidth count combining chars
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235870@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67276&edit=1 ID: 67276 Comment by: nicolasgrekas@php.net Reported by: nicolas dot grekas+php at gmail dot com Summary: mb_strwidth count combining chars Status: Not a bug Type: Bug Package: mbstring related PHP Version: 5.5.12 Assigned To: cmb Block user comment: N Private report: N New Comment: But then, the function is just broken for the purpose it should serve. For reference, there is standard on the topic, which is implemented in C at: https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c and in Python at https://github.com/jquast/wcwidth. In PHP, there is this: https://github.com/symfony/string/blob/bd53358e3eccec6a670b5f33ab680d8dbe1d4ae1/AbstractUnicodeString.php#L508 Previous Comments: ------------------------------------------------------------------------ [2021-08-16 15:14:02] cmb@php.net > Furthermore, mb_strwidth() appears to be useful for monospaced > fonts only. Not really, but still, there is nothing to fix here per my previous comment. ------------------------------------------------------------------------ [2018-03-11 14:41:17] cmb@php.net Not sure if this is a bug or rather a feature request. Anyhow, I guess it won't be fixed, since mbfl has no notion of combining characters, generally, and the grapheme_*() functions already cater to that. Furthermore, mb_strwidth() appears to be useful for monospaced fonts only. ------------------------------------------------------------------------ [2014-05-14 13:41:08] nicolas dot grekas+php at gmail dot com Description: ------------ combining characters should account for zero width when counted with mb_strwidth. Test script: --------------- <?php $a = 'é'; echo mb_strwidth($a, 'utf8'), "\n"; $b = Normalizer::normalize($a, Normalizer::NFD); echo mb_strwidth($b, 'utf8'), "\n"; Expected result: ---------------- 1 1 Actual result: -------------- 1 2 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67276&edit=1

« previous php.bugs (#235870) next »