zoukankan      html  css  js  c++  java
  • iOS 汉字转拼音

    - (NSString *)getFirstString:(ICCustom *)custom {
        NSMutableString *source = [custom.merchantAbbreviation mutableCopy];
        if(source && custom.merchantAbbreviation.length>0)
        {
            CFRange range = CFRangeMake(0, 1);
            CFStringTransform((__bridge CFMutableStringRef)source, &range, kCFStringTransformMandarinLatin, NO);
            CFStringTransform((__bridge CFMutableStringRef)source, &range, kCFStringTransformStripDiacritics, NO);
            NSString *phonetic = source;
            phonetic = [phonetic substringToIndex:1];
            phonetic = [phonetic uppercaseString];
            int temp = [phonetic characterAtIndex:0];
            if (temp < 65 || temp > 122 || (temp > 90 && temp < 97)) {
                //不合法的title
                phonetic = @"#";
            }else{
                phonetic = phonetic;
            }
            return phonetic;
        }else
        {
            return @"#";
        }
    }
  • 相关阅读:
    笔记2-斐波那契数列
    笔记1-排序
    C++ 顶层const和底层const ?
    C++指针常量与常量指针的区别?
    C++指针和引用的区别?
    函数指针, 指针函数?
    手机横竖屏问题
    Swift
    Swift 渐变色
    Swift guard 关键字
  • 原文地址:https://www.cnblogs.com/tian-sun/p/5909918.html
Copyright © 2011-2022 走看看