In this article, we will provide two solutions to solve the problem of multi-tone word sorting.
For example, the surname is read as Zeng, while the android app sorts it by Ceng.
: Modify the external/icu4c/data/coll/zh.txt file in the base.
Pinyin sorting is placed in the pinyin array. Taking Zeng as an example, we only need to move C to the end of Z.
: Intervene when converting Chinese characters to PinYin
Converting Chinese characters to Pinyin is completed by HanziToPinyin. java. The getToken function of this class defines a local variable offset,
After a series of comparisons with the UNIHANS array, the variable is assigned a value, which determines the pinyin corresponding to the Chinese character (the pinyin at the offset position in the PINYINS array ).
Therefore, if Pinyin is incorrect, it must be because the offset value is incorrect.
If we want to correct the Ordering Problem of polyphonic words, we only need to assign a value to offset.
Take Zeng as an example.
Make the following changes in the getToken function:
(cmp < 0-- (character== '\u66fe' && offset != 379"gaojx", "HanziToPinyin-->getToken()-->reset offset to 379 !!!!!"= 379"gaojx", "HanziToPinyin-->getToken()-->offset : " += ( j = 0; j < PINYINS[offset].length && PINYINS[offset][j] != 0; j++
Note: \ u66fe is a Unicode code. 379 is the offset corresponding to the pinyin ZENG.
In this way, Contacts will not put the last name under C but under Z when sorting it.
How to determine the offset of a Chinese pinyin in the pinyins array in a simple and fast manner?
A: print the offset Value in the source file. When creating a contact, use the Chinese character as the name to print the offset corresponding to the Chinese character.
The files after two schemes are modified: http://pan.baidu.com/share/link? Audio id = 592995 & uk = 2953765628 (all of which were corrected by multiphonograph)
Author blog: http://www.cnblogs.com/Lefter