标签:
//汉字转换为没有声调的没有空格的拼音
- (NSString *)transformToPinYin:(NSString *)wordStr {
首先转换的字符串必须是可变的字符串
NSString *wordStr=@”郑州”;
NSMutableString*mutableString=[NSMutableString stringWithString:wordStr];
//带声调的
CFStringTransform((CFMutableStringRef)mutableString, NULL, kCFStringTransformToLatin, false);
//不带声调的
CFStringTransform((CFMutableStringRef)mutableString, NULL, kCFStringTransformStripDiacritics, false);
//西安-> xi an (有空格)
return [mutableString stringByReplacingOccurrencesOfString:@" " withString:@""];
}
标签:
原文地址:http://www.cnblogs.com/zhao-jie-li/p/5049308.html