deha-soft / jp-string-helper
日语字符串助手,用于将全角字符串转换为半角字符串和反向。
v0.0.1
2022-03-13 14:53 UTC
Requires
- ext-mbstring: *
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-09-18 11:45:28 UTC
README
PHP日语字符串助手函数,用于将日语字符串从全角转换为半角和反向。
Laravel规则,用于验证仅全角或仅半角的日语字符串。
安装
- 您可以通过composer安装此包
composer require deha-soft/jp-string-helper
- 可选:服务提供者将自动注册。或者,您可以在config/app.php文件中手动添加服务提供者
'providers' => [ // ... DehaSoft\JpStringHelper\JpStrRulesServiceProvider::class, ];
用法
toHalfSize
和toFullSize
辅助函数的示例用法。
# using Transform import use DehaSoft\JpStringHelper\Transform; $fullSizeStr = "12345ザヂプabcd"; $output = Transform::toHalfSize($fullSizeStr); echo $output; >>> 12345ザヂプabcd $halfSizeStr = "12345ザヂプabcd"; $output = Transform::toFullSize($halfSizeStr); echo $output; >>> 12345ザヂプabcd
Laravel验证规则的示例用法。
# using Rule class import use DehaSoft\JpStringHelper\Rules\FullSize; use DehaSoft\JpStringHelper\Rules\HalfSize; public function rules() { return [ 'name' => [new FullSize()], 'description' => [new HalfSize()], ]; }
# or using rule alias public function rules() { return [ 'name' => ['full_size'], 'description' => ['half_size'], ]; }
许可协议
MIT许可协议(MIT)。请参阅许可文件以获取更多信息。