enorris/mbstring-stream
Composer 安装命令:
composer require enorris/mbstring-stream
包简介
An mbstring stream conversion filter.
README 文档
README
A php_user_filter implementation for quickly converting stream character sets without loading the entire string into memory.
Note: this library does not have the ability to persist state for stateful character sets, and as such, could potentially lose data. See #1 for an open issue, and this document for more info about stateful character sets.
Example
// Not required if the file was autoloaded (e.g. using composer) MultibyteStringStream::registerStreamFilter(); $native_file = fopen('iso-8859-1-file.txt', 'r'); stream_filter_append($native_file, 'convert.mbstring.UTF-8/ISO-8859-1'); $unicode_file = fopen('utf8-file.txt', 'w'); stream_copy_to_stream($native_file, $unicode_file);
mbstring-stream also works as a write filter:
$native_file = fopen('sjis-file.txt', 'r'); $unicode_file = fopen('utf8-file.txt', 'w'); stream_filter_append($unicode_file, 'convert.mbstring.UTF-8/SJIS'); stream_copy_to_stream($native_file, $unicode_file);
Usage
/** * resource $stream The stream to filter. * string $to_encoding The encoding to convert to. * string $from_encoding The encoding to convert from. Optional, defaults to mb_internal_encoding() * int $read_write See http://php.net/manual/en/function.stream-filter-append.php * string|int $sub_char The substitute character to use. Optional, defaults to mb_substitute_character() */ stream_filter_append($stream, "convert.mbstring.$to_encoding/$from_encoding", $read_write, $sub_char);
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 - once when writing to the stream, and once when reading from it.
enorris/mbstring-stream 适用场景与选型建议
enorris/mbstring-stream 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 91.01k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2016 年 04 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 enorris/mbstring-stream 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 enorris/mbstring-stream 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 91.01k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 37
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-04-23