#HanziPinyin A lightweight Swift library supporting convertion between Chinese(both Simplified and Tranditional) characters and Pinyin.
##How To Get Started
###Carthage
Specify "HanziPinyin" in your Cartfile
:
github "teambition/HanziPinyin"
###Usage
// PinyinToneType: none, toneNumber
// PinyinVCharType: vCharacter, uUnicode, uAndColon
// PinyinCaseType: lowercase, uppercase
let outputFormat = PinyinOutputFormat(toneType: .none, vCharType: .vCharacter, caseType: .lowercase)
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.
"我爱中文".toPinyin { (pinyin) in
// do something
}
"我爱中文".toPinyinAcronym { (pinyin) in
// do something
}
print("我爱中文".hasChineseCharacter)
// true
print("I love Chinese.".hasChineseCharacter)
// false
iOS 8.0
HanziPinyin is released under the MIT license. See LICENSE for details.
Have a question? Please open an issue!