PHPackages                             masakielastic/icu4x - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. masakielastic/icu4x

ActivePhp-ext[Utility &amp; Helpers](/categories/utility)

masakielastic/icu4x
===================

ICU4X PHP extension for Unicode text segmentation and East Asian Width, built with ext-php-rs

0.1.1(2mo ago)02MITPHPPHP &gt;=8.1

Since Feb 25Pushed 2mo agoCompare

[ Source](https://github.com/masakielastic/php-ext-icu4x)[ Packagist](https://packagist.org/packages/masakielastic/icu4x)[ RSS](/packages/masakielastic-icu4x/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

ICU4X PHP Extension
===================

[](#icu4x-php-extension)

A PHP extension for Unicode text segmentation using ICU4X, built with ext-php-rs.

Features
--------

[](#features)

- **Grapheme Cluster Segmentation**: Proper handling of Unicode text including emojis and complex scripts
- **East Asian Width Support**: Calculate display width of Unicode characters for proper text layout
- **Multiple APIs**: Both object-oriented class API and functional API
- **SPL Interface Support**: Full integration with PHP's Standard PHP Library interfaces
- **ICU4X 2.0**: Built on the latest ICU4X Unicode library
- **Memory Efficient**: Rust-based implementation with zero-copy optimizations

Installation
------------

[](#installation)

### Via PIE (Recommended)

[](#via-pie-recommended)

[PIE](https://github.com/php/pie) (PHP Installer for Extensions) allows you to install this extension directly from packagist.org.

```
pie install masakielastic/icu4x
```

Then add the extension to your php.ini:

```
extension=icu4x
```

### Manual Build

[](#manual-build)

#### Prerequisites

[](#prerequisites)

- Rust 1.70+
- PHP 8.1+
- ext-php-rs 0.14.0

1. Clone the repository:

```
git clone https://github.com/masakielastic/php-ext-icu4x.git
cd php-ext-icu4x
```

2. Build and install the extension:

```
cargo build --release
sudo cp target/release/libicu4x.so $(php-config --extension-dir)/icu4x.so
```

3. Add to php.ini:

```
echo "extension=icu4x" >> $(php-config --ini-path)/php.ini
```

Usage
-----

[](#usage)

### Function API (Recommended)

[](#function-api-recommended)

```
