fab2s/utf8
Composer 安装命令:
composer require fab2s/utf8
包简介
A purely static UTF8 Helper based on mb_string and ext-intl
README 文档
README
A purely static UTF-8 Helper based on mb_string and ext-intl
For sure this is not new, and there is better out there, but this is small and does the job without a lot of noise
Installation
Utf8 can be installed using composer:
composer require "fab2s/utf8"
Utf8 is also included in OpinHelper which packages several bellow "Swiss Army Knife" level Helpers covering some of the most annoying aspects of php programing, such as UTF8 string manipulation, high precision Mathematics or properly locking a file
Should you need to work with php bellow 7.1, you can still use OpinHelper 0.x
Prerequisites
Utf8 requires mb_string, ext-intl is auto detected and used when available for UTF-8 Normalization
In practice
Utf8 offers replacement for most native string functions with support for UTF-8:
-
Utf8::strrpos(string string $str, string $needle, int $offset = null):int|falseUTF-8 aware strrpos() replacement
-
Utf8::strpos(string $str, string $needle, int $offset = 0):int|falseUTF-8 aware strpos() replacement
-
Utf8::strtolower(string $str):stringUTF-8 aware strtolower() replacement
-
Utf8::strtoupper(string $str):stringUTF-8 aware strtoupper() replacement
-
Utf8::substr(string $str, int $offset, int $length = null):stringUTF-8 aware substr() replacement
-
Utf8::strlen(string $str):intUTF-8 aware strlen() replacement
-
Utf8::ucfirst(string $str):stringUTF-8 aware ucfirst() replacement
-
Utf8::ucwords(string $str):stringUTF-8 aware ucwords() replacement
-
Utf8::ord(string $chr):int|falseUTF-8 aware ord() replacement
-
Utf8::chr(int $num):string|falseUTF-8 aware chr() replacement
And some simple utility methods:
-
Utf8::normalize(string $string, int $canonicalForm = self::NORMALIZE_NFC):stringUTF-8 ext-intl Normalizer
WARNING: This method will do nothing in case
ext-intlis not installed on the host This means it is up to you to make sure about it usingUtf8::normalizerSupportor by addingext-intlas a requirement to your project'scomposer.jsonfile -
Utf8::hasUtf8(string $string):boolTells if the input string contains some UTF-8
-
Utf8::isUtf8(string $string):boolTells if the input string is valid UTF-8
-
Utf8::replaceMb4(string $string, string $replace = ''):string -
Utf8::normalizerSupport(bool $disable = false):boolTells if Normalizer is available or disable Normalizer support
Requirements
Utf8 is tested against php 7.2, 7.3, 7.4, 8.0 and 8.1
Contributing
Contributions are welcome, do not hesitate to open issues and submit pull requests.
License
Utf8 is open-sourced software licensed under the MIT license
fab2s/utf8 适用场景与选型建议
fab2s/utf8 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 323.61k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 08 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「intl」 「Simple」 「utf8」 「utf-8」 「helper」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 fab2s/utf8 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fab2s/utf8 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 fab2s/utf8 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easy to use internationalization functions for Laravel
A simple library for make Lexer and Parsers to build a language
A simple library that allows transform any kind of data to native php data or whatever
A simple library that uses the hydration pattern to fill objects given different sources of data.
Provides a customizable wrapper around Intl formatters to use it inside Laravel application. And also allows defining your own formats.
Micro Active Record library in PHP, support chain calls, events, and relations.
统计信息
- 总下载量: 323.61k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 31
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-12