GitHub - alecrabbit/php-wcwidth: Calculate width of unicode strings rendered to a terminal (original) (raw)
πΊπ¦ πΌ PHP Wide Character Width
This is kinda port of python's jquast/wcwidth
Installation
$ composer require alecrabbit/php-wcwidth
Quick start
use function AlecRabbit\WcWidth\wcwidth; use function AlecRabbit\WcWidth\wcswidth;
echo wcwidth('a'); // 1 echo wcwidth('Γ©'); // 1 echo wcwidth('π'); // 2 echo wcswidth('πππ'); // 6
echo wcwidth('πππ'); // 2 - only first char is considered
see doc/usage.md for more details.
FFI extension
Note βΌοΈ Experimental feature.
For improved performance, consider leveraging the Foreign Function Interface (FFI
) extension, if available. To enable this feature, set the USE_FFI
environment variable to true
.
Note When using
ffi
extensionversion
value is ignored completely.