sjorek / unicode-normalization-stream-filter
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
注意: 此包已被 Unicode-Normalization 包所取代!
一个提供规范Unicode流过滤器的composer包,目前仅支持utf8。
安装
php composer.phar require sjorek/unicode-normalization-stream-filter
示例
<?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);
使用
<?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 https://php.ac.cn/manual/en/function.stream-filter-append.php * @link https://php.ac.cn/manual/en/function.stream-filter-prepend.php */ stream_filter_append($stream, "convert.unicode-normalization.$form", $read_write);
注意:在使用r+
或w+
(或类似)模式下的流时请小心;默认情况下PHP将过滤器分配给读取和写入链。这意味着它将尝试两次转换数据 - 一次在从流中读取时,一次在写入时。
贡献
查看贡献指南