sjorek / unicode-normalization-stream-filter
This package is abandoned and no longer maintained.
The author suggests using the sjorek/unicode-normalization package instead.
A stream filter to normalize unicode, currently only utf8.
v0.0.8
2017-10-18 18:06 UTC
Requires
- php: >=7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.7
- patchwork/utf8: ^1.3
- phpunit/phpunit: ^6.4
- symfony/polyfill-intl-normalizer: ^1.6
Suggests
- ext-iconv: This stream filter can use a php-based implementation utilizing 'iconv'-extension and one of the other three Normalizer-implementations to provide a special unicode-normalization for HFS+ filesystems
- ext-intl: This stream filter can use 'intl'-extension's native Normalizer-implementation to provide unicode-normalization in preference of the suggested php-based 'symfony/polyfill-intl-normalizer' or 'patchwork/utf8'package
- patchwork/utf8: This stream filter can use the php-based Normalizer-implementation from 'patchwork/utf8' package to provide unicode-normalization, but 'intl'-extensions' native implementation is preferred
- symfony/polyfill-intl-normalizer: This stream filter can use the php-based Normalizer-implementation from 'symfony/polyfill-intl-normalizer' package to provide unicode-normalization, but 'intl'-extensions' native implementation is preferred
This package is not auto-updated.
Last update: 2022-02-01 13:10:22 UTC
README
ATTENTION: This package has been replaced by the Unicode-Normalization package!
A composer-package providing a stream filter to normalize unicode, currently only utf8.
Installation
php composer.phar require sjorek/unicode-normalization-stream-filter
Example
<?php \Sjorek\UnicodeNormalization\StreamFilter::register(); $in_file = fopen('utf8-file.txt', 'r'); $out_file = fopen('utf8-normalized-to-nfc-file.txt', 'w'); // It works as a read filter: stream_filter_append($in_file, 'convert.unicode-normalization.NFC'); // And it also works as a write filter: // stream_filter_append($out_file, 'convert.unicode-normalization.NFC'); stream_copy_to_stream($in_file, $out_file);
Usage
<?php /** * @var $stream resource The stream to filter. * @var $form string The form to normalize unicode to. * @var $read_write int STREAM_FILTER_* constant to override the filter injection point * * @link http://php.net/manual/en/function.stream-filter-append.php * @link http://php.net/manual/en/function.stream-filter-prepend.php */ stream_filter_append($stream, "convert.unicode-normalization.$form", $read_write);
Note: Be careful when using on streams in r+
or w+
(or similar) modes; by default PHP will assign the
filter to both the reading and writing chain. This means it will attempt to convert the data twice - first when
reading from the stream, and once again when writing to it.
Contributing
Look at the contribution guidelines