diff --git a/src/Pinyin/Pinyin.php b/src/Pinyin/Pinyin.php index dbdb014f..ad932e57 100644 --- a/src/Pinyin/Pinyin.php +++ b/src/Pinyin/Pinyin.php @@ -158,13 +158,12 @@ public static function parse($string, array $settings = array()) $string = $instance->justChinese($string); } - $pinyin = $instance->string2pinyin($string); - + $source = $instance->string2pinyin($string); // add accents if ($settings['accent']) { - $pinyin = $instance->addAccents($pinyin); + $pinyin = $instance->addAccents($source); } else { - $pinyin = $instance->removeTone($pinyin); + $pinyin = $instance->removeTone($source); } //add delimiter @@ -173,7 +172,7 @@ public static function parse($string, array $settings = array()) $return = array( 'src' => $string, 'pinyin' => $instance->escape($delimitedPinyin), - 'letter' => $instance->getFirstLetters($pinyin, $settings), + 'letter' => $instance->getFirstLetters($source, $settings), ); return $return; diff --git a/tests/TestCase.php b/tests/TestCase.php index 93a4be8e..71e1bc68 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,7 +1,11 @@ assertEquals('z y', Pinyin::letter('重要')); $this->assertEquals('nh', Pinyin::letter('您好', array('delimiter' => ''))); $this->assertEquals('kxll', Pinyin::letter('康熙来了', array('delimiter' => ''))); + $this->assertEquals('A B Z Z Q Z Z Z Z', Pinyin::letter("阿坝藏族羌族自治州", array('uppercase' => true))); $this->assertEquals('d z x w q l x b d d z d g m h', Pinyin::letter('带着希望去旅行,比到达终点更美好')); $this->assertEquals('z q s l z w z w', Pinyin::letter('赵钱孙李 周吴郑王')); }