C 漢字轉換拼音技術詳解(高效能)

2022-02-22 09:07:35 字數 2124 閱讀 7701

通過網上漢字轉換成拼音的**,經過本人優化,效能將更加優異。

下面將源**貼出。

[csharp]view plain

copy

public

static

class

chinesetopinyin  

, , , , , , ,   

, , , , , ,   

, , , , , , ,   

, , , , , , ,  

, , , , , ,   

, , , , , ,   

, , , , , ,  

, , , , , ,   

, , , , , , ,  

, , , , , ,   

, , , , , , ,   

, , , , , , ,  

, , , , , ,   

, , , , , , , ,  

, , , , , ,   

, , , , , , ,  

, , , , , , ,  

, , , , , ,   

, , , , , ,   

, , , , , ,   

, , , , , ,   

, , , , , , ,  

, , , , , ,   

, , , , , , ,   

, , , , , , ,   

, , , , , ,   

, , , , , , ,  

, , , , , , ,  

, , , , , ,   

, , , , , ,   

, , , , , , ,   

, , , , , ,   

, , , , , , ,   

, , , , , ,   

, , , , , , , ,  

, , , , , ,   

, , , , , , ,  

, , , , , ,  

, , , , , ,   

, , , , , ,   

, , , , , , ,   

, , , , , , ,   

, , , , , , ,   

, , , , , ,  

, , , , , ,  

, , , , , ,   

, , , , , , ,  

, , , , , ,   

, , , , , ,   

, , , , , ,   

, , , , , , ,   

, , , , , , ,   

, , , , , ,   

, , , , , , ,  

, , , , , ,   

, , , , , ,  

, , , , , ,   

, , , , , ,   

, , , , , ,   

, , , , , ,   

, , , , , ,   

, ,  };  

///   

///   漢字轉拼音 

///   

///   需要轉換的漢字 

///   返回漢字對應的拼音 

public

static

string

topinyin(

string

txt)  

arr1 = (short

)(arr[0]);   

//取位元組1 

arr2 = (short

)(arr[1]);   

//取位元組2 

charcode = arr1 * 256 + arr2 - 65536;//計算漢字的編碼 

if(charcode > -10254 || charcode < -20319)  

//如果不在漢字編碼範圍內則不改變 

else

}  }  else

}  }  return

result.tostring();  

}  }  

C 漢字轉換拼音技術詳解(高效能)

public static class chinesetopinyin 漢字轉拼音 需要轉換的漢字 返回漢字對應的拼音 public static string topinyin string txt arr1 short arr 0 取位元組1 arr2 short arr 1 取位元組2 cha...

C 漢字轉換拼音技術詳解

private static readonly dictionarycodecollections new dictionary,漢字轉拼音 需要轉換的漢字 返回漢字對應的拼音 public static string topinyin string txt arr1 short arr 0 取位元...

C 將漢字轉換為拼音(按照拼音搜尋)

可以將漢字字串的首字母提取出來,例如 產品名稱 蒙牛酸酸乳,提取後 mnssr,可用於按照拼音查詢。比如 你想查詢某人姓名,只需輸入名字縮寫即可,還有其它的用處,你可以自己挖掘。如果覺得對你有用,別忘了頂一下,謝謝!csharp view plain copy print using system ...