Skip to content

Latest commit

 

History

History
28 lines (18 loc) · 946 Bytes

README.md

File metadata and controls

28 lines (18 loc) · 946 Bytes

UTF-8 sanitizer

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).