PHPackages                             rayblair06/unicode - 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. rayblair06/unicode

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

rayblair06/unicode
==================

Type-Safe Unicode Characters

2.0.0(1y ago)73MITPHPPHP ^8.0CI passing

Since Mar 6Pushed 1y ago2 watchersCompare

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

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Unicode PHP Class
=================

[](#unicode-php-class)

A well-structured and easy-to-use PHP class providing access to Unicode utilities. This class allows working with Unicode characters in a **type-safe and explicit** manner for PHP applications by providing constants and methods to retrieve subsets of characters, escape Unicode sequences, and more.

---

⚡ Features
----------

[](#-features)

- **Unicode constants** for type-safe and explicit declarations
- **Retrieve all Unicode constants** defined in the class
- **Fetch a subset of Unicode constants** by count or range
- **Convert UTF-8 characters to Unicode escape sequences**
- **Provides structured access** to Unicode symbols
- **Ensures strict type safety for better maintainability**

---

🔥 Example
---------

[](#-example)

```
use Rayblair\Unicode\Unicode;

echo Unicode::HYPHEN_MINUS; // Outputs: -

$mappings = [
    Unicode::EN_DASH => Unicode::HYPHEN_MINUS,
    Unicode::EM_DASH => Unicode::HYPHEN_MINUS,
];
```

---

🚀 Installation
--------------

[](#-installation)

1. Install via Composer:

```
composer require rayblair/unicode
```

---

📚 Usage
-------

[](#-usage)

### Basic Usage

[](#basic-usage)

```
use Rayblair\Unicode\Unicode;

// Get single Unicode constant
print_r(Unicode::HYPHEN_MINUS); // Outputs: -

// Get all Unicode constants
print_r(Unicode::getAll());

// Get first 10 Unicode constants
print_r(Unicode::get(10));

// Get Unicode characters within a specific range
print_r(Unicode::range('0041', '0044'));

// Convert UTF-8 characters into Unicode escape sequences
echo Unicode::escape('A'); // Outputs \u0041
```

---

⚙️ Methods
----------

[](#️-methods)

### `getAll()`

[](#getall)

Returns an associative array of all defined Unicode constants.

```
print_r(Unicode::getAll());
```

Output Example:

```
Array
(
    [LATIN_CAPITAL_LETTER_A] => A
    [LATIN_CAPITAL_LETTER_B] => B
    [LATIN_SMALL_LETTER_A] => a
)
```

### `get(int $count)`

[](#getint-count)

Returns a subset of Unicode constants up to the given count.

```
print_r(Unicode::get(5));
```

### `range(string $start, string $end)`

[](#rangestring-start-string-end)

Returns a subset of Unicode constants within a specified Unicode hex range.

```
print_r(Unicode::range('0041', '0044'));
```

Output:

```
Array
(
    [LATIN_CAPITAL_LETTER_A] => A
    [LATIN_CAPITAL_LETTER_B] => B
    [LATIN_CAPITAL_LETTER_C] => C
    [LATIN_CAPITAL_LETTER_D] => D
)
```

### `escape(string $utf8String)`

[](#escapestring-utf8string)

Converts UTF-8 characters into Unicode escape sequences (`\uXXXX`).

```
echo Unicode::escape('Hello, 😊!'); // Outputs: \u0048\u0065\u006c\u006c\u006f, \u1F60A!
```

---

🌍 Compatibility
---------------

[](#-compatibility)

- PHP 8.0 and above

---

🚀 Contribution
--------------

[](#-contribution)

Contributions are welcome! If you have improvements or additional Unicode symbols to add, feel free to:

1. Fork the repository
2. Create a new branch
3. Make your changes
4. Submit a pull request

---

⚖️ License
----------

[](#️-license)

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.

---

📞 Contact
---------

[](#-contact)

For issues or suggestions, feel free to open an issue on GitHub.

---

⭐ Support
---------

[](#-support)

If you find this project useful, consider giving it a ⭐ on GitHub!

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance44

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

437d ago

Major Versions

1.0.0 → 2.0.02025-03-07

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab35ad2244c1203e3b7f0fdbe2d765fcdcf92c4b51cddee2b82e522c841f4650?d=identicon)[rayblair06](/maintainers/rayblair06)

---

Top Contributors

[![rayblair06](https://avatars.githubusercontent.com/u/16214725?v=4)](https://github.com/rayblair06 "rayblair06 (4 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/rayblair06-unicode/health.svg)

```
[![Health](https://phpackages.com/badges/rayblair06-unicode/health.svg)](https://phpackages.com/packages/rayblair06-unicode)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
