Comparison of ios methods for obtaining Chinese pinyin

Source: Internet
Author: User

1. The size of pinyin is the smallest, and the declaration of POAPinyin is about 500 rows.

2. The speed is almost the same, but do not use the convert of POAPinyin native. It is very slow to traverse and search every time.

3. Compared with pinyin, you can only obtain the first letter of the Chinese character corresponding to the pinyin alphabet. PYMethod was originally used for stock query, and its pinyin number is less than that of POAPinyin.

For this Chinese character "hmm", I typed the Pinyin Input Method "en", PYMethod obtained EN, but POAPinyin obtained NG, Baidu encyclopedia also read NG .....

4. Principles

Pinyin extracts the first letter of the Chinese character in unicode to the array. When the array is obtained, the [unicode value of Chinese characters-the starting Chinese character value in unicode] is obtained directly.

PYMethod converts unicode to GBK. Then, the location of the corresponding Pinyin is determined based on the two values of GBK.

POAPinyin makes up a table of all the Chinese characters corresponding to pinyin, and then queries the table (native convert method)

The improved quickConvert method is to first obtain an upper and lower limit of the unicode value of Chinese characters, and then convert the above table into a unicode-pinyin table. During query, it is a hash query, which is faster, if unicode is not continuous, there will be a big problem (the word in this table is missing :"? G? I? K is still ????????????? X? Z? {???? Parameters ???? | Throw? Y shent ???????????????????? Brewed ??? TB "). This function will skip some non-ascii characters. Another method, stringConvert, fixes the problem of non-ascii code. It is best to add the words mentioned above to the table.

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.