Skip to content

Releases: Yurunsoft/ChineseUtil

v2.0.5

14 Oct 02:15
Compare
Choose a tag to compare
  • 修复 Money::toChinese() 整数以 0 结束时的问题

v2.0.4

15 Apr 03:02
Compare
Choose a tag to compare
  • 修复 Memory 模式的拼音分词,传入空字符串报错问题
  • 格式化代码

v2.0.3

02 Feb 03:22
Compare
Choose a tag to compare

v2.0.2

31 Dec 07:28
Compare
Choose a tag to compare
  • 修复单独解析多音字拼音首字母时的问题
  • 修复 Money::toChinese() bug #8 #9
  • FFI 现在支持了 7.4、8.0
  • Github actions 迁移,干掉狗日的 travis

减少安装后不必要的文件

21 Sep 03:11
Compare
Choose a tag to compare
v2.0.1

减少安装后不必要的文件

v2.0.0

17 Aug 08:48
d75eb0f
Compare
Choose a tag to compare
  • 支持 FFI、Swoole FFI

  • 重构拼音分词算法

  • 拼音分词支持可选获取数组或字符串数组的结果集

支持 PHP 7.4

06 Dec 06:11
Compare
Choose a tag to compare

支持 PHP 7.4

测试用例加持,保证类库稳定性

26 Aug 07:01
Compare
Choose a tag to compare
  • 修复一系列因 PHP 版本、环境、模式,导致的转换差异问题

  • 测试用例加持,保证类库稳定性

修复 [] operator not supported for strings

14 Jan 01:12
Compare
Choose a tag to compare

修复 [] operator not supported for strings

新增中文数字转换、人民币大写转换

17 Dec 08:45
Compare
Choose a tag to compare

更新内容

  • 新增中文数字转换、人民币大写转换
  • 新增支持不分割无拼音字符的选项

数字转换

use Yurun\Util\Chinese\Number;
function test($number)
{
    $chinese = Number::toChinese($number, [
        'tenMin'    =>  true, // “一十二” => “十二”
    ]);
    $afterNumber = Number::toNumber($chinese);
    echo $number, '=>', $chinese, '=>', $afterNumber, '=>', 0 === bccomp($number, $afterNumber, 20) ? 'true' : 'false', PHP_EOL;
}

test(1.234);
test(-1234567890.666);
test(pi());
/**
输出结果:
1.234=>一点二三四=>1.234=>true
-1234567890.666=>负十二亿三千四百五十六万七千八百九十点六六六=>-1234567890.666=>true
3.1415926535898=>三点一四一五九二六五三五八九八=>3.1415926535898=>true
 */

金额数字转换

use Yurun\Util\Chinese\Money;
function test($number)
{
    $chinese = Money::toChinese($number, [
        'tenMin'    =>  true, // “一十二” => “十二”
    ]);
    $afterMoney = Money::toNumber($chinese);
    echo $number, '=>', $chinese, '=>', $afterMoney, '=>', 0 === bccomp($number, $afterMoney) ? 'true' : 'false', PHP_EOL;
}

test(1.234);
test(-1234567890.666);
/**
输出结果:
1.234=>壹圆贰角叁分肆厘=>1.234=>true
-1234567890.666=>负壹拾贰亿叁仟肆佰伍拾陆万柒仟捌佰玖拾圆陆角陆分陆厘=>-1234567890.666=>true
 */

不分割无拼音字符

use \Yurun\Util\Chinese;
use \Yurun\Util\Chinese\Pinyin;
$string = '恭喜發財!123';

echo '分割无拼音字符:', PHP_EOL;
var_dump(Chinese::toPinyin($string, Pinyin::CONVERT_MODE_PINYIN, '-'));

echo '不分割无拼音字符:', PHP_EOL;
var_dump(Chinese::toPinyin($string, Pinyin::CONVERT_MODE_PINYIN, '-', false));
分割无拼音字符:
array(1) {
  'pinyin' =>
  array(1) {
    [0] =>
    string(24) "gong-xi-fa-cai-!-1-2-3"
  }
}
不分割无拼音字符:
array(1) {
  'pinyin' =>
  array(1) {
    [0] =>
    string(21) "gong-xi-fa-cai-!123"
  }
}