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