object c中文拼音排序

2021-09-07 23:55:10 字數 370 閱讀 1616

objective-c 和 sqlite 不支援中文拼音排序,這讓中文應用的開發者非常鬱悶 ,通過使用pingyin.h就能實現獲取到字元首字母

1。在資料庫中為每個資料項加乙個字段,用於存放漢字的漢語拼音首字母,比如 唐就是t,好就是h....這樣就能用 sql 語句對首字母進行排序了,其實就是根據拼音排序

建議將 pinyin.c 改為 .cpp,此時會報錯,只需 static char firstletterarray[hanzi_count+1] 改這句話就好了。改完後就能在 .mm 或 .cpp 檔案中使用了

使用方法如下

#import

"pinyin.h

" char0

例項**

**  

中文字元按拼音排序

select from select 張三 name from dual union all select 李四 name from dual union all select 王五 name from dual order by nlssort name,nls sort schinese pin...

Python根據拼音對中文排序

對中文排序時,順序並不是想象中的按 拼音 排 print sorted 美國 中國 日本 美m 中z 日r abcdefghijkl m nopq r stuvwsy z 中國 日本 美國 安裝pypinyin pip install pypinyin coding utf 8 author xer...

中文轉拼音

中文轉拼音的類c 實現 code using system using system.collections.generic using system.text using system.collections endregion 獲得漢字的拼音,如果輸入的是英文本元將原樣輸出,中文標點符號將被忽略...