漢字拼音簡碼

2021-07-28 19:11:06 字數 1804 閱讀 9106

///

/// 獲取乙個漢字的拼音聲母

///

/// unicode格式的乙個漢字

///

public static char convert(char chinese)

);byte asciibytes = encoding.convert(unicode, gb2312, unicodebytes);

//   計算該漢字的gb-2312編碼   

int n = (int)asciibytes[0] << 8;

n += (int)asciibytes[1];

//   根據漢字區域碼獲取拼音聲母   

if (in(0xb0a1, 0xb0c4, n)) return 'a';

if (in(0xb0c5, 0xb2c0, n)) return 'b';

if (in(0xb2c1, 0xb4ed, n)) return 'c';

if (in(0xb4ee, 0xb6e9, n)) return 'd';

if (in(0xb6ea, 0xb7a1, n)) return 'e';

if (in(0xb7a2, 0xb8c0, n)) return 'f';

if (in(0xb8c1, 0xb9fd, n)) return 'g';

if (in(0xb9fe, 0xbbf6, n)) return 'h';

if (in(0xbbf7, 0xbfa5, n)) return 'j';

if (in(0xbfa6, 0xc0ab, n)) return 'k';

if (in(0xc0ac, 0xc2e7, n)) return 'l';

if (in(0xc2e8, 0xc4c2, n)) return 'm';

if (in(0xc4c3, 0xc5b5, n)) return 'n';

if (in(0xc5b6, 0xc5bd, n)) return 'o';

if (in(0xc5be, 0xc6d9, n)) return 'p';

if (in(0xc6da, 0xc8ba, n)) return 'q';

if (in(0xc8bb, 0xc8f5, n)) return 'r';

if (in(0xc8f6, 0xcbf0, n)) return 's';

if (in(0xcbfa, 0xcdd9, n)) return 't';

if (in(0xcdda, 0xcef3, n)) return 'w';

if (in(0xcef4, 0xd188, n)) return 'x';

if (in(0xd1b9, 0xd4d0, n)) return 'y';

if (in(0xd4d1, 0xd7f9, n)) return 'z';

return '\0';

}private static bool in(int lp, int hp, int value)

protected void page_load(object sender, eventargs e)

protected void button1_click(object sender, eventargs e)

///

/// 獲取一串漢字的拼音聲母

///

/// unicode格式的漢字字串

/// 拼音聲母字串

public static string convert(string chinese)

return new string(buffer);

}

C 實現漢字拼音簡碼

using system using system.collections.generic using system.text using microsoft.visualbasic namespace trancepy console.write 該系列漢字的拼音簡碼分別為 strpy n sta...

獲取輸入漢字的拼音簡碼

public class getpinyin private static int table new int 27 private static maprarewords private static mapbookfamilynames private static mapbookfamilys...

sql 生成拼音簡碼函式

if exists select from sysobjects where name fun getpy drop function fun getpy gocreate function fun getpy str nvarchar 4000 returns nvarchar 4000 asbe...