How to solve the problem of multi-tone word sorting errors in Contacts

Source: Internet
Author: User

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

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.