コード例 #1
0
ファイル: SlugTest.php プロジェクト: cawa0505/php-thl-pinyin
 public function testSpecialCharacters()
 {
     $source = '特殊字元~!@#$%^&*()_+{}|:"<>?-=[]\\;\',./';
     $expect = 'teshu-zihyuan------------_-------------------';
     $output = Pinyin::slug($source);
     $this->assertSame($expect, $output);
 }
コード例 #2
0
 public function testMixedWithSpaces()
 {
     $source = ' THL 台灣華語 THL 羅馬拼音 THL ';
     $expect = ' THL ㄊㄞˊ ㄨㄢ ㄏㄨㄚˊ ㄩˇ THL ㄌㄨㄛˊ ㄇㄚˇ ㄆㄧㄣ ㄧㄣ THL ';
     $output = Pinyin::bpmf($source);
     $this->assertSame($expect, $output);
     $source = '  THL  台灣華語  THL  羅馬拼音  THL  ';
     $expect = '  THL  ㄊㄞˊ ㄨㄢ ㄏㄨㄚˊ ㄩˇ  THL  ㄌㄨㄛˊ ㄇㄚˇ ㄆㄧㄣ ㄧㄣ  THL  ';
     $output = Pinyin::bpmf($source);
     $this->assertSame($expect, $output);
 }
コード例 #3
0
 public function testTonelessWithSpaces()
 {
     $source = ' 台灣華語 羅馬拼音 THL ';
     $expect = ' tai wan hua yu luo ma pin yin THL ';
     $output = Pinyin::pinyin($source, array("tone" => "none", "split" => "word"));
     $this->assertSame($expect, $output);
     $source = ' 台灣華語 羅馬拼音 THL ';
     $expect = ' taiwan huayu luoma pinyin THL ';
     $output = Pinyin::pinyin($source, array("tone" => "none", "split" => "phrase"));
     $this->assertSame($expect, $output);
     $source = ' 仁愛白鵝 海鷗長女 ';
     $expect = " ren'ai bai'e hai'ou jhang'nyu ";
     $output = Pinyin::pinyin($source, array("tone" => "none", "split" => "phrase"));
     $this->assertSame($expect, $output);
 }