C 漢字轉換拼音技術詳解

2021-06-10 15:54:06 字數 1971 閱讀 7308

private static readonly dictionarycodecollections = new dictionary, , , , , , ,    

, , , , , ,   

, , , , , , ,    

, , , , , , ,   

, , , , , ,    

, , , , , ,    

, , , , , ,   

, , , , , ,    

, , , , , , ,   

, , , , , ,   

, , , , , , ,    

, , , , , , ,   

, , , , , ,   

, , , , , , , ,   

, , , , , ,   

, , , , , , ,   

, , , , , , ,   

, , , , , ,    

, , , , , ,    

, , , , , ,    

, , , , , ,    

, , , , , , ,   

, , , , , ,   

, , , , , , ,    

, , , , , , ,    

, , , , , ,    

, , , , , , ,   

, , , , , , ,   

, , , , , ,    

, , , , , ,    

, , , , , , ,    

, , , , , ,   

, , , , , , ,    

, , , , , ,   

, , , , , , , ,   

, , , , , ,    

, , , , , , ,   

, , , , , ,   

, , , , , ,    

, , , , , ,   

, , , , , , ,   

, , , , , , ,   

, , , , , , ,    

, , , , , ,   

, , , , , ,   

, , , , , ,    

, , , , , , ,   

, , , , , ,    

, , , , , ,    

, , , , , ,   

, , , , , , ,   

, , , , , , ,    

, , , , , ,    

, , , , , , ,   

, , , , , ,    

, , , , , ,   

, , , , , ,    

, , , , , ,    

, , , , , ,    

, , , , , ,    

, , , , , ,   

, , };

///  

///   漢字轉拼音    

///  

///   需要轉換的漢字

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

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 漢字轉換拼音技術詳解(高效能)

通過網上漢字轉換成拼音的 經過本人優化,效能將更加優異。下面將源 貼出。csharp view plain copy public static class chinesetopinyin 漢字轉拼音 需要轉換的漢字 返回漢字對應的拼音 public static string topinyin s...

漢字轉換拼音函式

呼叫convertpinyin 函式,引數為你要轉換的漢字 返回值就是轉換後的拼音 可以只返回首字母或者首字母大寫的全拼拼音 var phonetictranscriptionobj 漢字轉拼音 function convertpinyin chinesecharacter else if name...