codeinc / utf8-sanitizer
Sanitize UTF-8 strings
Installs: 51
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/codeinc/utf8-sanitizer
Requires
- php: >=8.0
- ext-iconv: *
Requires (Dev)
- phpunit/phpunit: ^9
- spatie/ray: ^1.34
README
A simple UTF-8 sanitizer written in PHP 8 using iconv. This code is based after this StackOverflow response and the W3C UTF-8 verification recommended regular expression.
Usage
<?php $sanitizer = new \CodeInc\Utf8Sanitizer\Utf8Sanitizer(); // validates a UTF-8 string $sanitizer->isValidUtf8("A valid UTF-8 string."); // true // sanitizes a string $validString = $sanitizer->sanitize("An invalid UTF-8 string.");
Installation
This library is available through Packagist and can be installed using Composer:
composer require codeinc/utf8-sanitizer
License
This library is published under the MIT license (see the LICENSE file).