HanziPinyin

A lightweight Swift library supporting convertion between Chinese(both Simplified and Tranditional) characters and Pinyin.

Showing:

Popularity

Downloads/wk

0

GitHub Stars

47

Maintenance

Last Commit

2yrs ago

Contributors

3

Package

Dependencies

0

License

MIT

Categories

Readme

HanziPinyin

A lightweight Swift library supporting convertion between Chinese(both Simplified and Tranditional) characters and Pinyin.

Example

How To Get Started

Carthage

Specify "HanziPinyin" in your Cartfile:

github "teambition/HanziPinyin"

CocoaPods

Specify "HanziPinyin" in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'HanziPinyin'

Usage

Pinyin output format

// PinyinToneType: none, toneNumber
// PinyinVCharType: vCharacter, uUnicode, uAndColon
// PinyinCaseType: lowercased, uppercased, capitalized
let outputFormat = PinyinOutputFormat(toneType: .none, vCharType: .vCharacter, caseType: .lowercased)

Convert to Pinyin synchronously

print("我爱中文".toPinyin(withFormat: outputFormat, separator: " "))
// wo ai zhong wen

print("我愛說中國話".toPinyin(withFormat: outputFormat, separator: " "))
// wo ai shuo zhong guo hua

print("我爱中文".toPinyinAcronym())
// wazw

print("I love Chinese.".toPinyin())
// I love Chinese.

Convert to Pinyin asynchronously

"我爱中文".toPinyin { (pinyin) in
    // do something
}

"我爱中文".toPinyinAcronym { (pinyin) in
    // do something
}

Chinese character detecting

print("我爱中文".hasChineseCharacter)
// true
print("I love Chinese.".hasChineseCharacter)
// false

Minimum Requirement

iOS 8.0

Release Notes

License

HanziPinyin is released under the MIT license. See LICENSE for details.

More Info

Have a question? Please open an issue!

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100