汉字转拼音

NSString * hanziText = @"12你好a,haha";

    if ([hanziText length]) {

        NSMutableString *ms = [[NSMutableString alloc] initWithString:hanziText];

        if (CFStringTransform((__bridge CFMutableStringRef)ms, 0, kCFStringTransformMandarinLatin, NO)) {

            NSLog(@"pinyin: %@", ms);

        }

        if (CFStringTransform((__bridge CFMutableStringRef)ms, 0, kCFStringTransformStripDiacritics, NO)) {

            NSLog(@"pinyin: %@", ms);

        }  

    }

你可能感兴趣的:(OC,语言)