iOS-NSString汉子转拼音

释放双眼,带上耳机,听听看~!
//
//  ViewController.m
//  QQQQQ
//
//  Created by ZFJ_APPLE on 16/1/8.
//  Copyright © 2016年岁月轻狂. All rights reserved.
//
 
#import "ViewController.h"
 
@interface ViewController ()
 
@end
 
@implementation ViewController
 
- (void)viewDidLoad {
    [superviewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self uiConfig];
}
 
- (void)uiConfig
{
    NSString *str = @"岁月轻狂_杰";
    NSMutableString *mutableStr = [str mutableCopy];
    //CFRange range = CFRangeMake(0, str.length);
    //NULL  默认全部转换
    //汉子转拼音有音标
    BOOL ret =CFStringTransform((__bridgeCFMutableStringRef)mutableStr, NULL,kCFStringTransformMandarinLatin, NO);
    if(ret)
    {
        NSLog(@"%@",mutableStr);
    }
    //汉子转拼音无音标
    BOOL ret1 =CFStringTransform((__bridgeCFMutableStringRef)mutableStr, NULL,kCFStringTransformStripDiacritics, NO);
    if(ret1)
    {
        NSLog(@"%@",mutableStr);
    }
 
}
 
- (void)didReceiveMemoryWarning {
    [superdidReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
 
@end
2016-01-08 14:21:21.837 QQQQQ[4357:211360] suì yuè qīng kuáng_jié

2016-01-08 14:21:21.847 QQQQQ[4357:211360] sui yue qing kuang_jie

 

人已赞赏
iOS文章

iOS去掉navigationBar下面的一条横线

2019-11-1 12:20:02

iOS文章

UIWebView实现自动登陆(存储、读取Cookie)

2019-11-1 18:18:18

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
有新消息 消息中心
搜索