Convert Chinese characters to Pinyin and Chinese characters to PinYin
Engineering Drawing:
This code needs to import the third-party library ChineseToPinyinDemo.
Code:
# Import "ViewController. h "# import" ChineseToPinyin. h "@ interface ViewController () @ end @ implementation ViewController-(void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. self. title = @ "converting Chinese characters to PinYin"; NSString * pinYinString = [ChineseToPinyin pinyinFromChiniseString: @ "I Love You"]; NSLog (@ "--- pinyin --- % @ -----", pinYinString ); NSLog (@ "-- first letter-% @ -----", [pinYinString substringToIndex: 1]);}
Output:
10:11:51. 168 ChineseToPinyinDemo [1832: 66705] --- pinyin --- WOAINI-----2014-12-18 10:11:51. 169 ChineseToPinyinDemo [1832: 66705] -- the first letter-W -----