rowbot/punycode
Composer 安装命令:
composer require rowbot/punycode
包简介
A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA).
README 文档
README
An implementation of RFC 3492 Punycode in PHP, based on the sample implementation in Appendix C.
This is NOT a substitue for idn_to_ascii and idn_to_utf8.
Requirements
- PHP 7.1+
Installation
composer require rowbot/punycode
API
Punycode::decode(string $input, int $outLength = null, array &$caseFlags = [])
The Punycode::decode() method takes an ASCII encoded string and decodes it to a UTF-8 encoded
string. Optionally, the second parameter can be specified to place a limit on the size of the
returned string.
Parameters
$input- An ASCII encoded punycode string to convert to a UTF-8 encoded string.$outLength- A positive integer representing the maximum length, in code points, of the resulting output string. Defaults to 2,147,483,647.$caseFlags- An array, which will have the case flag of each character inserted into it.
Throws
\Rowbot\Punycode\Exception\OutputSizeExceededException- If the size of the output string exceeds the maximum size specified.\Rowbot\Punycode\Exception\OverflowException- If integer overflow occurs.\Rowbot\Punycode\Exception\InvalidInputException- If input contains non-ASCII bytes or mapping a code point to a digit fails.
use Rowbot\Punycode\Punycode; try { echo Punycode::decode('Hello-Another-Way--fc4qua05auwb3674vfr0b'); // Hello-Another-Way-それぞれの場所 } catch (\Rowbot\Punycode\Exception\PunycodeException $e) { echo 'An error occured!'; }
Punycode::encode(string $input, int $outLength = null, array $caseFlags = [])
The Punycode::encode() method takes a UTF-8 encoded string and converts it into an ASCII encoded
punycode string. Optionally, the second parameter can be specified to place a limit on the size of
the returned string.
Parameters
$input- A UTF-8 encoded string to convert to punycode.$outLength- A positive integer representing the maximum length, in code points, of the resulting output string. Defaults to 2,147,483,647.$caseFlags- An array of bools where true indicates that the character should be uppercase and false indicates that it should be lowercase. This only affects ASCII characters[a-zA-Z].
Throws
\Rowbot\Punycode\Exception\OutputSizeExceededException- If the size of the output string exceeds the maximum size specified.\Rowbot\Punycode\Exception\OverflowException- If integer overflow occurs.
use Rowbot\Punycode\Punycode; try { echo Punycode::encode('Hello-Another-Way-それぞれの場所'); // Hello-Another-Way--fc4qua05auwb3674vfr0b } catch (\Rowbot\Punycode\Exception\PunycodeException $e) { echo 'An error occured!'; }
rowbot/punycode 适用场景与选型建议
rowbot/punycode 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 249.12k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 06 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「punycode」 「rfc3492」 「rfc-3492」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rowbot/punycode 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rowbot/punycode 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rowbot/punycode 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Package for encoding of Unicode for Internationalized Domain Names in Applications (IDNA)
PHP library to convert Domain Names correctly from IDN to Punycode, and vice-versa also offers TR46 processing.
RFC 3492 Punycode encoding and decoding for internationalized domain names
A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA)
A collection of useful classes that deals with UTF-8 strings, URLs, punycode, form validation and more
A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA)
统计信息
- 总下载量: 249.12k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 24
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-06-02