2017 © Pedro Peláez
 

library zhuyin-pinyin

A PHP library that deals with Zhuyin to Pinyin and Pinyin to Zhuyin.

image

dictpedia/zhuyin-pinyin

A PHP library that deals with Zhuyin to Pinyin and Pinyin to Zhuyin.

  • Monday, April 2, 2018
  • by dictpedia
  • Repository
  • 1 Watchers
  • 2 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 25 % Grown

The README.md

ZhuyinPinyin

A PHP library that deals with Zhuyin (注音) to Pinyin (漢語拼音), Pinyin to Zhuyin., (*1)

https://github.com/localvar/zhuyin (Golang version), (*2)

The original idea is from a Golang library written by Bomin Zhang, I recoding it with PHP and using on DictPedia project., (*3)

For example, this library will translate zhang1 to zhāng (pinyin) or ㄓㄤ (zhuyin), zhāng or ㄓㄤ decode to zhang1, and also support pinyin to zhuyin and zhuyin to pinyin., (*4)

這個函式庫的原始邏輯設計出自以 Golang 編寫,因為本人需要用在字典百科專案中,但尋無以 PHP 版本實現的注音轉拼音、拼音轉注音的函式庫,所以我把它從 Golang 改寫成 PHP 版本。, (*5)

  • 此PHP 版與 Golang 原版的差別是捨棄字串陣列,分別讀取個別字元進去陣列以避免可能的 UTF-8字元問題
  • 原始邏輯已經處理的很好了,所以直接移植為 PHP 版本。只加了一個函式 splitString 來處理個別 UTF-8 字元

Install

composer require dictpedia/zhuyin-pinyin

Usage

$zh = new \DictPedia\ZhuyinPinyin();

Resutn empty string if the input string is invaild., (*6)

API

encodePinyin

echo $zh->encodePinyin('zhang1');

// result: zhāng

decodePinyin

echo $zh->decodePinyin('zhāng');

// result: zhang1

encodeZhuyin

echo $zh->encodeZhuyin('zhang1');

// result: ㄓㄤ

decodeZhuyin

echo $zh->decodeZhuyin('ㄓㄤ');

// result: zhang1

pinyinToZhuyin

echo $zh->pinyinToZhuyin('zhāng');

// result: ㄓㄤ

zhuyinToPinyin

echo $zh->zhuyinToPinyin('ㄓㄤ');

// result: zhāng

License

MIT, (*7)

https://packagist.org/packages/dictpedia/zhuyin-pinyin, (*8)

The Versions

02/04 2018

dev-master

9999999-dev https://github.com/DictPedia/ZhuyinPinyin

A PHP library that deals with Zhuyin to Pinyin and Pinyin to Zhuyin.

  Sources   Download

MIT

The Requires

  • php >=5.3.9

 

The Development Requires

php pinyin chinese zhuyin

11/03 2017

1.0

1.0.0.0 https://github.com/DictPedia/ZhuyinPinyin

A PHP library that deals with Zhuyin to Pinyin and Pinyin to Zhuyin.

  Sources   Download

MIT

The Requires

  • php >=5.3.9

 

The Development Requires

php pinyin chinese zhuyin