A comparison of the methods for obtaining Chinese pinyin from iOS

Source: Internet
Author: User
Tags comparison

1. Pinyin the smallest size, Poapinyin's statement is almost 500 lines.

2. The speed is in fact similar to three, but do not use the Poapinyin native of that convert, that each time traversal lookup is very slow.

3. Contrast pinyin can only get the first letter of Chinese phonetic Alphabet, Pymethod was originally applied to the stock query, its number of pinyin is less than poapinyin.

For this Chinese character "hmm", I pinyin Input method is "en" dozen out, Pymethod get is en, but poapinyin get is Ng, Baidu Encyclopedia also read ng ...

4. Principle

Pinyin is to extract the first letter of the Chinese character in Unicode to the array, when the pinyin array [Chinese character's Unicode value-unicode the initial Chinese character value] is obtained directly.

Pymethod is to convert Unicode into GBK, and then according to GBK High and low two values to determine the position of the corresponding phonetic pinyin

Poapinyin is to put all the pinyin and the corresponding Chinese characters into a table, then to this list query (native Convert method)

The improved Quickconvert method is to get the upper and lower limit of the Unicode value of the Chinese character, and then convert the table above into unicode--Pinyin, the query is hash lookup, faster, if this Unicode is not continuous there will be a big problem ( There was a lack of words in the table: "? G?i?k still????????????? X?z? {???? Di She???? | Leng throw? Y-Matt???????????????????? Stuffed??? Terbium "). This function also skips some non-ASCII symbols. Another method Stringconvert fixes the problem of non-ASCII code. It is best to add the words mentioned above into the table when using.

Demo

Related Article

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.