Skip to content

PHP Japanese string helper functions for converting Japanese strings from full-width to half-width and reverse. Laravel Rule for validation Japanese string only full-width or only half-width.

Notifications You must be signed in to change notification settings

deha-soft/jp-string-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Japanese String Helpers

PHP Japanese string helper functions for converting Japanese strings from full-width to half-width and reverse.
Laravel Rule for validation Japanese string only full-width or only half-width.

Installation

  1. You can install the package via composer:
composer require deha-soft/jp-string-helper
  1. Optional: The service provider will automatically get registered. Or you may manually add the service provider in your config/app.php file:
'providers' => [
    // ...
    DehaSoft\JpStringHelper\JpStrRulesServiceProvider::class,
];

Usage

Example use of the toHalfSize, toFullSize helper.

# 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

Example use of the Rule for Laravel validation.

# 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'],
    ];
}

License

The MIT License (MIT). Please see License File for more information.

About

PHP Japanese string helper functions for converting Japanese strings from full-width to half-width and reverse. Laravel Rule for validation Japanese string only full-width or only half-width.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages