Skip to content

Repository files navigation

🇺🇦 🇼 PHP Wide Character Width

PHP VersionBuild Status

Build StatusScrutinizer Code QualityCode Coverage

Latest Stable VersionLatest Stable VersionLatest Unstable Version

LicenseTotal Downloads

This is kinda port of python's jquast/wcwidth

🌐 Unicode release files

Installation

$ composer require alecrabbit/php-wcwidth

Quick start

usefunctionAlecRabbit\WcWidth\wcwidth;
usefunctionAlecRabbit\WcWidth\wcswidth;
echowcwidth('a'); // 1echowcwidth('é'); // 1echowcwidth('🐘'); // 2echowcswidth('🐘🐘🐘'); // 6echowcwidth('🐘🐘🐘'); // 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.

USE_FFI=true

Note When using ffi extension version value is ignored completely.

About

Calculate width of unicode strings rendered to a terminal

Topics

Resources

Code of conduct

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages