swift

1.汉字转拼音

func pinYinZChines(content:String)->String{
     
    let transformContents = CFStringCreateMutableCopy(nil, 0, content)
     
    CFStringTransform( transformContents, nil, kCFStringTransformMandarinLatin, false)
     
    CFStringTransform( transformContents, nil, kCFStringTransformStripDiacritics, false)
     
    let ztransformContents = transformContents as String
     
    let index = ztransformContents.startIndex.advancedBy(0)
     
    let firstString = ztransformContents[index]
     
    let stringZ = String.init(firstString)
     
    return stringZ.uppercaseString
     
}
posted @ 2016-09-23 22:20  starainDou  阅读(271)  评论(0编辑  收藏  举报