显示SQLite中的 GET_PHONEBOOK_INDEX 函数是在2010.3.3才加入的,也就是说,可能2.0之后的很多老机器都不支持该函数,需要自己去实现,
This function will produce a normalized upper case first letterfrom a given string.Bug: 2407129Change-Id: Idfafca04342d43ef43cfdff0e431e0a6a8cf5c68android/Android.mk patch | blob | historyandroid/PhonebookIndex.cpp [new file with mode: 0644] patch | blobandroid/PhonebookIndex.h [new file with mode: 0644] patch | blobandroid/sqlite3_android.cpp patch | blob | history
而且看了C++代码(./external/sqlite/android/PhonebookIndex.cpp)发现,有很多字符处理都是直接返回0的:
/** * Returns TRUE if the character belongs to a Hanzi unicode block */static bool is_CJK(UChar c) { return (0x4e00 <= c && c <= 0x9fff) // CJK_UNIFIED_IDEOGRAPHS || (0x3400 <= c && c <= 0x4dbf) // CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A || (0x3000 <= c && c <= 0x303f) // CJK_SYMBOLS_AND_PUNCTUATION || (0x2e80 <= c && c <= 0x2eff) // CJK_RADICALS_SUPPLEMENT || (0x3300 <= c && c <= 0x33ff) // CJK_COMPATIBILITY || (0xfe30 <= c && c <= 0xfe4f) // CJK_COMPATIBILITY_FORMS || (0xf900 <= c && c <= 0xfaff); // CJK_COMPATIBILITY_IDEOGRAPHS}int32_t GetPhonebookIndex(UCharIterator * iter, const char * locale, UChar * out, int32_t size, UBool * isError){ if (size < MIN_OUTPUT_SIZE) { *isError = TRUE; return 0; } *isError = FALSE; // Normalize the first character to remove accents using the NFD normalization UErrorCode errorCode = U_ZERO_ERROR; int32_t len = unorm_next(iter, out, size, UNORM_NFD, 0 /* options */, TRUE /* normalize */, NULL, &errorCode); if (U_FAILURE(errorCode)) { *isError = TRUE; return 0; } if (len == 0) { // Empty input string return 0; } UChar c = out[0]; // We are only interested in letters if (!u_isalpha(c)) { return 0; } c = u_toupper(c); // Check for explicitly mapped characters UChar c_mapped = map_character(c, DEFAULT_CHAR_MAP, sizeof(DEFAULT_CHAR_MAP) / sizeof(UChar)); if (c_mapped != 0) { out[0] = c_mapped; return 1; } // Convert Kanas to Hiragana UChar next = len > 2 ? out[1] : 0; c = android::GetNormalizedCodePoint(c, next, NULL); // Traditional grouping of Hiragana characters if (0x3042 <= c && c <= 0x309F) { if (c < 0x304B) c = 0x3042; // a else if (c < 0x3055) c = 0x304B; // ka else if (c < 0x305F) c = 0x3055; // sa else if (c < 0x306A) c = 0x305F; // ta else if (c < 0x306F) c = 0x306A; // na else if (c < 0x307E) c = 0x306F; // ha else if (c < 0x3084) c = 0x307E; // ma else if (c < 0x3089) c = 0x3084; // ya else if (c < 0x308F) c = 0x3089; // ra else c = 0x308F; // wa out[0] = c; return 1; } if (is_CJK(c)) { if (strncmp(locale, "ja", 2) == 0) { // Japanese word meaning "misc" or "other" out[0] = 0x4ED6; return 1; } else { return 0; } } out[0] = c; return 1;}
倒是对日语支持的很好啊。
原文链接: https://www.cnblogs.com/mengshu-lbq/archive/2011/06/27/2091299.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/27738
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!