Skip to content

Calculate width of unicode strings rendered to a terminal

License

Notifications You must be signed in to change notification settings

alecrabbit/php-wcwidth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

b11c159 Β· May 10, 2024
Jan 5, 2021
May 10, 2024
Dec 4, 2023
Dec 4, 2023
Dec 4, 2023
Jul 26, 2023
Jan 23, 2024
Feb 28, 2024
Feb 28, 2024
Dec 4, 2023
Mar 3, 2023
Jul 26, 2023
Mar 17, 2023
Mar 5, 2023
Mar 17, 2023
Mar 3, 2023
Sep 12, 2023
Mar 4, 2023
Feb 27, 2023
Jun 2, 2023
Sep 21, 2023
Mar 2, 2023
Dec 4, 2023
Dec 4, 2023
Mar 3, 2023
Jan 23, 2024
Mar 3, 2023
Jun 2, 2023
Jun 2, 2023
Jun 2, 2023

Repository files navigation

πŸ‡ΊπŸ‡¦ πŸ‡Ό PHP Wide Character Width

PHP Version Build Status

Build Status Scrutinizer Code Quality Code Coverage

Latest Stable Version Latest Stable Version Latest Unstable Version

License Total Downloads

This is kinda port of python's jquast/wcwidth

🌐 Unicode release files

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.

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

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published