Kanji to pinyin, Chinese pinyin sequencer

Source: Internet
Author: User

Kanji to Pinyin


nsmutablestring *ms = [[Nsmutablestring alloc] initwithstring:@"I am a Chinese"];if(Cfstringtransform (__bridge cfmutablestringref) MS,0, Kcfstringtransformmandarinlatin, NO)) {NSLog (@"pingying:%@", MS);//Wǒshìzhōng Guórén}if(Cfstringtransform (__bridge cfmutablestringref) MS,0, Kcfstringtransformstripdiacritics, NO)) {NSLog (@"pingying:%@", MS);//wo shi Zhong guo ren}

Chinese Pinyin Sequencer

#define Gb18030_encoding cfstringconvertencodingtonsstringencoding (kcfstringencodinggb_18030_2000) + (NSComparator) Compor {  return ^nscomparisonresult (nsstring *obj1, NSString *obj2) {    *str1 = [obj1 Stringbyaddingpercentescapesusingencoding:gb18030_encoding];     *STR2 = [Obj2 stringbyaddingpercentescapesusingencoding:gb18030_encoding];     return [str1 compare:str2];}  ;}

Principle: Chinese GB encoding is to use pinyin sort of hack a bit: In the stringbyaddingpercentescapesusingencoding: back with 16-bit code to convert Chinese to ASCII to compare more concise.

Kanji to pinyin, Chinese pinyin sequencer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.