国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

【C#】輸入漢字字符串索引拼音的首字母

2024-07-21 02:30:21
字體:
來源:轉載
供稿:網友
在做項目的時候,輸入客戶的名字,為了方便索引漢字字符串的拼音首字母,作助記碼,于是到網上找了一下,還好,有個單個漢字的處理!為了答謝該網友!為了以后的網友,我做了漢字字符串的處理!
還請各位網友指教[email protected]!
using system;
using system.drawing;
using system.collections;
using system.componentmodel;
using system.windows.forms;
using system.data;

namespace winmarket
{
/// <summary>
/// classfun 的摘要說明。
/// </summary>
public class classfun
{
private string capstr;

public classfun()
{
//
// todo: 在此處添加構造函數邏輯
//
}
public string chinesecap(string chinesestr)
{


byte[] zw = new byte[2];
long chinesestr_int;
string charstr,chinastr="";
for (int i=0;i<=chinesestr.length-1;i++)
{
charstr=chinesestr.substring(i,1).tostring();
zw=system.text.encoding.default.getbytes(charstr);
// 得到漢字符的字節數組
if(zw.length==2)
{
int i1 = (short)(zw[0]);
int i2 = (short)(zw[1]);
chinesestr_int=i1*256+i2;
//table of the constant list
// 'a'; //45217..45252
// 'b'; //45253..45760
// 'c'; //45761..46317
// 'd'; //46318..46825
// 'e'; //46826..47009
// 'f'; //47010..47296
// 'g'; //47297..47613

// 'h'; //47614..48118
// 'j'; //48119..49061
// 'k'; //49062..49323
// 'l'; //49324..49895
// 'm'; //49896..50370
// 'n'; //50371..50613
// 'o'; //50614..50621
// 'p'; //50622..50905
// 'q'; //50906..51386

// 'r'; //51387..51445
// 's'; //51446..52217
// 't'; //52218..52697
//沒有u,v
// 'w'; //52698..52979
// 'x'; //52980..53640
// 'y'; //53689..54480
// 'z'; //54481..55289

if ((chinesestr_int>=45217) && (chinesestr_int<=45252))
{
chinastr= "a";
}
else if ((chinesestr_int>=45253) && (chinesestr_int<=45760))
{
chinastr= "b";
}
else if ((chinesestr_int>=45761) && (chinesestr_int<=46317))
{
chinastr= "c";

}
else if ((chinesestr_int>=46318) && (chinesestr_int<=46825))
{
chinastr= "d";
}
else if ((chinesestr_int>=46826) && (chinesestr_int<=47009))
{
chinastr= "e";
}
else if ((chinesestr_int>=47010) && (chinesestr_int<=47296))
{
chinastr= "f";
}
else if ((chinesestr_int>=47297) && (chinesestr_int<=47613))
{
chinastr= "g";
}
else if ((chinesestr_int>=47614) && (chinesestr_int<=48118))
{

chinastr= "h";
}

else if ((chinesestr_int>=48119) && (chinesestr_int<=49061))
{
chinastr= "j";
}
else if ((chinesestr_int>=49062) && (chinesestr_int<=49323))
{
chinastr= "k";
}
else if ((chinesestr_int>=49324) && (chinesestr_int<=49895))
{
chinastr= "l";
}
else if ((chinesestr_int>=49896) && (chinesestr_int<=50370))
{
chinastr= "m";
}

else if ((chinesestr_int>=50371) && (chinesestr_int<=50613))
{
chinastr= "n";

}
else if ((chinesestr_int>=50614) && (chinesestr_int<=50621))
{
chinastr= "o";
}
else if ((chinesestr_int>=50622) && (chinesestr_int<=50905))
{
chinastr= "p";

}
else if ((chinesestr_int>=50906) && (chinesestr_int<=51386))
{
chinastr= "q";

}

else if ((chinesestr_int>=51387) && (chinesestr_int<=51445))
{
chinastr= "r";
}
else if ((chinesestr_int>=51446) && (chinesestr_int<=52217))
{
chinastr= "s";
}
else if ((chinesestr_int>=52218) && (chinesestr_int<=52697))
{
chinastr= "t";
}
else if ((chinesestr_int>=52698) && (chinesestr_int<=52979))
{
chinastr= "w";
}
else if ((chinesestr_int>=52980) && (chinesestr_int<=53640))
{
chinastr= "x";
}
else if ((chinesestr_int>=53689) && (chinesestr_int<=54480))
{
chinastr= "y";
}
else if ((chinesestr_int>=54481) && (chinesestr_int<=55289))
{
chinastr= "z";
}

}
else
{
capstr=chinesestr;
break;
}

capstr=capstr+chinastr;
}



return capstr;

}


}
}

最大的網站源碼資源下載站,

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 淮北市| 宁强县| 察哈| 乐至县| 东海县| 剑阁县| 高青县| 涡阳县| 迭部县| 济阳县| 五指山市| 仙居县| 鄂州市| 荣成市| 曲水县| 敦煌市| 本溪市| 佛坪县| 武隆县| 莱州市| 腾冲县| 淮安市| 资溪县| 忻州市| 南江县| 鄂伦春自治旗| 荔浦县| 鄯善县| 四会市| 都匀市| 娱乐| 读书| 策勒县| 巴楚县| 资兴市| 洛阳市| 华阴市| 苏尼特右旗| 江门市| 宣武区| 承德县|