美文网首页
文字转拼音

文字转拼音

作者: 英雄出少年 | 来源:发表于2018-08-30 10:58 被阅读15次
@interface TGConvertPY : NSObject
+ (TGConvertPY *)sharedInstance;
- (NSString *)toPinyin: (NSString *)source;
@end

@interface TGConvertPY()
{
    int     *_codeIndex;
    char    *_pinyin;
    BOOL    _inited;
}

@end

@implementation TGConvertPY

+ (TGConvertPY *)sharedInstance
{
    static TGConvertPY *instance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[TGConvertPY alloc] init];
    });
    return instance;
}

- (NSString *)toPinyin: (NSString *)source
{
    if ([source length] == 0)
    {
        return nil;
    }
    NSMutableString *mutableString = [NSMutableString stringWithString:source];
    CFStringTransform((CFMutableStringRef)mutableString, NULL, kCFStringTransformToLatin, false);
    mutableString = (NSMutableString *)[mutableString stringByFoldingWithOptions:NSDiacriticInsensitiveSearch locale:[NSLocale currentLocale]];
    return [mutableString stringByReplacingOccurrencesOfString:@"'" withString:@""];
}

相关文章

  • 文字转拼音

  • js文字转拼音(Convert_Pinyin.js)

    js文字转拼音 Convert_Pinyin.js 事例

  • Python 拼音汉字互转

    汉字转拼音:pypinyin拼音转汉字:Pinyin2Hanzi Python汉字转拼音-拼音转汉字的效率测评

  • JS插件-中文转拼音

    中文转拼音插件Convert_Pinyin.js 需求:输入框前的前五个描述文字转换为拼音写入name中提交for...

  • iOS 文字转拼音方法的比较

    基于《iOS开发中如何更快的实现汉字转拼音》 方法列举 A. 最终版 项目中直接采用了这种方法,原因:处理速度快。...

  • python汉字转拼音

    场景说明 把中文汉字、转成汉语拼音,包括: 纯汉字转拼音 汉字里面加有字母转拼音 转加声调的拼音 转用数字表示声调...

  • Java中文按照拼音排序(含中文)

    添加maven,中文转拼音 工具jar 中文转拼音 排序封装类 使用

  • iOS-汉字转拼音(未完待续)

    Core Foundation包含文字转拼音的相应方法,而且还支持声调。具体过程如下: 首先假设有一段文字NSSt...

  • 汉字转拼音

    汉字转拼音有很多种方法, 在这里推荐一个在线的免费转拼音的网站。 点击访问??汉字转拼音??

  • 汉字转拼音

    几种方法 一种是建立一个拼音对应的汉字map,进行查表。一种是利用汉字编码,根据不同的区域求出拼音。 第一种的原...

网友评论

      本文标题:文字转拼音

      本文链接:https://www.haomeiwen.com/subject/ofjrwftx.html