日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

汉字转拼音缩写的函数以及其他函数

發(fā)布時間:2024/4/17 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 汉字转拼音缩写的函数以及其他函数 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
/**////?<summary>
????????
///?清空指定頁面上所有的控件內(nèi)容,包括TextBox,CheckBox,CheckBoxList,RadioButton,RadioButtonList。但是不清
????????
///?除如ListBox,DropDownList,因為這樣的控件值對當前頁面來說還可以用,一般這些控件里都是保存的字典數(shù)據(jù)。
????????
///?Author:Kevin
????????
///?日期:2004-12-02
????????
///?</summary>
????????
///?<param?name="page">?指定的頁面</param>?

????????public?static?void?ClearAllContent(System.Web.UI.Control?page)
????????
{
????????????
int?nPageControls?=?page.Controls.Count;
????????????
for?(int?i?=?0;?i?<?nPageControls;?i++)
????????????
{
????????????????
foreach?(System.Web.UI.Control?control?in?page.Controls[i].Controls)
????????????????
{
????????????????????
if?(control.HasControls())
????????????????????
{
????????????????????????ClearAllContent(control);?
????????????????????}

????????????????????
else
????????????????????
{?
????????????????????????
if?(control?is?TextBox)
????????????????????????????(control?
as?TextBox).Text?=?"";

????????????????????????
if?(control?is?CheckBox)
????????????????????????????(control?
as?CheckBox).Checked?=?false;

????????????????????????
if?(control?is?RadioButtonList)
????????????????????????????(control?
as?RadioButtonList).SelectedIndex?=?-1;

????????????????????????
if?(control?is?RadioButton)
????????????????????????????(control?
as?RadioButton).Checked?=?false;

????????????????????????
if?(control?is?CheckBoxList)
????????????????????????
{
????????????????????????????
foreach?(ListItem?item?in?(control?as?CheckBoxList).Items)
????????????????????????????
{
????????????????????????????????item.Selected?
=?false;
????????????????????????????}

????????????????????????}

????????????????????}
//if..else
????????????????}
//foreach
????????????}
//for
????????}
/**////?<summary>
????????
///?漢字轉拼音縮寫
????????
///?Code?By?MuseStudio@hotmail.com
????????
///?
????????
///?</summary>
????????
///?<param?name="str">要轉換的漢字字符串</param>
????????
///?<returns>拼音縮寫</returns>

????????public?string?GetPYString(string?str)
????????
{
????????????
string?tempStr?=?"";
????????????
foreach(char?c?in?str)
????????????
{
????????????????
if((int)c?>=?33?&&?(int)c?<=126)
????????????????
{//字母和符號原樣保留
????????????????????tempStr?+=?c.ToString();
????????????????}

????????????????
else
????????????????
{//累加拼音聲母
????????????????????tempStr?+=?GetPYChar(c.ToString());
????????????????}

????????????}

????????????
return?tempStr;
????????}


????????
/**////?<summary>
????????
///?取單個字符的拼音聲母
????????
///?Code?By?MuseStudio@hotmail.com
????????
///?2004-11-30
????????
///?</summary>
????????
///?<param?name="c">要轉換的單個漢字</param>
????????
///?<returns>拼音聲母</returns>

????????public?string?GetPYChar(string?c)
????????
{
????????????
byte[]?array?=?new?byte[2];
????????????array?
=?System.Text.Encoding.Default.GetBytes(c);
????????????
int?i?=?(short)(array[0]?-?'\0')?*?256?+?((short)(array[1]?-?'\0'));

????????????
if?(?i?<?0xB0A1)?return?"*";
????????????
if?(?i?<?0xB0C5)?return?"a";
????????????
if?(?i?<?0xB2C1)?return?"b";
????????????
if?(?i?<?0xB4EE)?return?"c";
????????????
if?(?i?<?0xB6EA)?return?"d";
????????????
if?(?i?<?0xB7A2)?return?"e";
????????????
if?(?i?<?0xB8C1)?return?"f";
????????????
if?(?i?<?0xB9FE)?return?"g";
????????????
if?(?i?<?0xBBF7)?return?"h";
????????????
if?(?i?<?0xBFA6)?return?"g";
????????????
if?(?i?<?0xC0AC)?return?"k";
????????????
if?(?i?<?0xC2E8)?return?"l";
????????????
if?(?i?<?0xC4C3)?return?"m";
????????????
if?(?i?<?0xC5B6)?return?"n";
????????????
if?(?i?<?0xC5BE)?return?"o";
????????????
if?(?i?<?0xC6DA)?return?"p";
????????????
if?(?i?<?0xC8BB)?return?"q";
????????????
if?(?i?<?0xC8F6)?return?"r";
????????????
if?(?i?<?0xCBFA)?return?"s";
????????????
if?(?i?<?0xCDDA)?return?"t";
????????????
if?(?i?<?0xCEF4)?return?"w";
????????????
if?(?i?<?0xD1B9)?return?"x";
????????????
if?(?i?<?0xD4D1)?return?"y";
????????????
if?(?i?<?0xD7FA)?return?"z";

????????????
return?"*";
????????}
//作用:把ListBox中的全部內(nèi)容轉換成一個字符串,各個字段間用,分隔
??
//
??
//參數(shù):Lists,需要轉換的ListBox.items
??
//
??
//返回值:轉換好的字符串
??
//
??public?string?ListToString(ListItemCollection?Lists)
??
{
???
string?result="";
???
for(int?i=0;i<Lists.Count;i++)
???
{
????
if?(i==0)
????
{
?????result
=Lists[i].Text;
????}

????
else
????
{
?????result
=result+","+Lists[i].Text;
????}

???}

???
return?result;
??}
?

??
//
??
//作用:把string中的全部內(nèi)容轉換成ListItemCollection從而綁定到Listbox
??
//
??
//參數(shù):str,需要轉換的字符串
??
//
??
//返回值:轉換好的ListItemCollection
??
//
??public?ListItemCollection?StringToList(string?str)
??
{
???ListItemCollection?lists
=new?ListItemCollection();
???
if(str=="")????????????????????????????????????????//字符串為空
???{
????errPosition
="ListItemCollection";
????errMsg
="字符串為空";
???}

???
else?if(str.IndexOf(",")==0)????????????????????????//首位為","
???{
????errPosition
="ListItemCollection";
????errMsg
="首位為,";
???}

???
else?if(str.Substring(str.Length-1,1)==",")????????//尾位為","
???{
????errPosition
="ListItemCollection";
????errMsg
="尾位為,";
???}

???
else
???
{
????
while?(str.IndexOf(",")>0)
????
{
?????
int?position=str.IndexOf(",")?;
?????lists.Add(str.Substring(
0,position));
?????str
=str.Remove(0,position+1);
????}

????lists.Add(str);
???}

???
return?lists;
??}


??
//
??
//作用:把源ListBox中的選中數(shù)據(jù)移動到目標ListBox
??
//
??
//參數(shù):FromLists,源ListBox
??
//
??public?static?void?MoveListBoxSelectedItem
???(ListItemCollection?FromLists,ListItemCollection?ToLists)
??
{
???
for(int?i=FromLists.Count-1;i>=0;i--)
???
{
????
if?(FromLists[i].Selected)
????
{
?????FromLists[i].Selected
=false;
?????ToLists.Add(FromLists[i]);
?????FromLists.Remove(FromLists[i]);
????}

???}

??}


??
//
??
//作用:把源ListBox中的全部數(shù)據(jù)移動到目標ListBox
??
//
??
//參數(shù):FromLists,源ListBox
??
//
??public?static?void?MoveListBoxAllItem
???(ListItemCollection?FromLists,ListItemCollection?ToLists)
??
{
???
for(int?i=FromLists.Count-1;i>=0;i--)
???
{
????FromLists[i].Selected
=false;
????ToLists.Add(FromLists[i]);
????FromLists.Remove(FromLists[i]);
???}

??}


??
//
??
//作用:輸入年月返回月份的天數(shù)的集合
??
//
??
//參數(shù):YYYY年,MM月
??
//
??
//返回值:本月的天數(shù)的ArrayList
??
//
??public?static?ArrayList?GetDaysInMonth(int?YYYY,int?MM)
??
{
???
int?day=DateTime.DaysInMonth(YYYY,MM);
???ArrayList?days
=new?ArrayList();
???
for?(int?i=1;i<=day;i++)
???
{
????days.Add(i);
???}

???
return?days;
??}



??
//
??
//作用:輸入選中天數(shù)的集合,返回其中的最小和最大的天數(shù)
??
//
??
//參數(shù):dates,把Calendar.SelectedDates傳入即可
??
//
??
//返回值:兩個數(shù)值的ArrayList,第一個為最小天數(shù),第二個為最大天數(shù)
??
//
??public?static?ArrayList?GetMinMaxDate(SelectedDatesCollection?dates)
??
{
???ArrayList?Result
=new?ArrayList();
???DateTime?min
=new?DateTime();
???DateTime?max
=new?DateTime();
???
for(int?i=0;i<dates.Count;i++)
???
{
????
if?(i>0)
????
{
?????
if(dates[i]<min)
?????
{
??????min
=dates[i];
?????}

?????
if(dates[i]>max)
?????
{
??????max
=dates[i];
?????}

????}

????
else
????
{
?????min
=dates[i];
?????max
=dates[i];
????}

???}

???Result.Add(min);
???Result.Add(max);
???
return?Result;
??}


調(diào)用函數(shù)是碰到ListItemCollection?使用ListBox.Items做參數(shù)

轉載于:https://www.cnblogs.com/cxd4321/archive/2007/03/08/667772.html

總結

以上是生活随笔為你收集整理的汉字转拼音缩写的函数以及其他函数的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。