📄 手机短信息的编程.htm
字号:
<DIV class=postbody>=========================</DIV>
<DIV class=postbody>大家不用惊慌,.NET 3.0依然搭建在.NET 2.0的运行环境上,最多也就算是.NET 2.5。</DIV>
<DIV class=postbody>RTM包括:</DIV>
<DIV class=postbody>Windows Presentation Foundation <BR>Windows Communication
Foundation <BR>Windows Workflow Foundation <BR>Windows CardSpace </DIV>
<DIV class=postbody><BR>.NET 3 Runtime 下载:<BR>Download the full x86
redistributable <BR><A
href="http://go.microsoft.com/fwlink/?LinkId=70848">http://go.microsoft.com/fwlink/?LinkId=70848</A><BR>Download
the full x64 redistributable<BR><A
href="http://go.microsoft.com/fwlink/?LinkId=70849">http://go.microsoft.com/fwlink/?LinkId=70849</A></DIV>
<DIV class=postbody>Windows SDK For .NET Framework 3.0 下载:<BR><A
href="http://www.microsoft.com/downloads/info.aspx?na=40&p=3&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=10cc340b-f857-4a14-83f5-25634c3bf043&u=http%3a%2f%2fgo.microsoft.com%2ffwlink%2f%3fLinkId%3d74726">http://www.microsoft.com/downloads/info.aspx?na=40&p=3&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=10cc340b-f857-4a14-83f5-25634c3bf043&u=http%3a%2f%2fgo.microsoft.com%2ffwlink%2f%3fLinkId%3d74726</A></DIV>
<DIV class=postbody>Microsoft Visual Studio 2005 Extensions for Windows WorkFlow
Foundation 下载:<BR><A
href="http://www.microsoft.com/downloads/info.aspx?na=40&p=4&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=10cc340b-f857-4a14-83f5-25634c3bf043&u=http%3a%2f%2fgo.microsoft.com%2ffwlink%2f%3fLinkId%3d74727">http://www.microsoft.com/downloads/info.aspx?na=40&p=4&SrcDisplayLang=en&SrcCategoryId=&SrcFamilyId=10cc340b-f857-4a14-83f5-25634c3bf043&u=http%3a%2f%2fgo.microsoft.com%2ffwlink%2f%3fLinkId%3d74727</A></DIV>
<DIV class=postbody>WCF和WPF的VS2005扩展包还没有正式发布。</DIV>
<DIV class=postbody></DIV>
<DIV
class=postbody>引用于:http://community.csdn.net/Expert/topic/5140/5140038.xml?temp=.7662622</DIV>
<DIV class=postbody></DIV></DIV> <A
href="http://liujace.itpub.net/post/4284/240967">查看全文</A>
<P></P><BR style="CLEAR: both"></DIV>
<DIV class=contentcomments><A class=commentfoot
href="http://liujace.itpub.net/post/4284/240967#comments">评论 (0)</A> <A
class=commentfoot href="http://liujace.itpub.net/trackbacks/4284/240967">引用
(0)</A> <A class=commentfoot
href="http://liujace.itpub.net/category/4284/10421">手机编程[3]</A> <A
class=commentfoot href="http://liujace.itpub.net/category/4284/7950">技术资源[7]</A>
<A class=commentfoot
href="http://liujace.itpub.net/category/4284/7956">开源项目[1]</A> <A
class=commentfoot
href="http://liujace.itpub.net/category/4284/7955">C#编程[11]</A> <A
class=commentfoot
href="http://liujace.itpub.net/category/4284/42845">随心记事[0]</A> </DIV></DIV>
<DIV class=post><!-- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"><rdf:Description rdf:about="http://liujace.itpub.net/post/4284/240865" dc:identifier="http://liujace.itpub.net/post/4284/240865" dc:title="MSDN WebCast下载中心" trackback:ping="http://blog.itpub.net//trackback.php?id=240865"/></rdf:RDF> -->
<DIV class=contenttitle><A href="http://liujace.itpub.net/post/4284/240865">MSDN
WebCast下载中心</A></DIV>
<DIV class=contenttime>liujace - by - 15 十二月, 2006 09:05</DIV>
<DIV id=blogbody>
<P>
<P>MSDN WebCast下载中心</P>
<P><A
href="http://www.microsoft.com/china/msdn/events/webcasts/shared/webcast/downloadarchive.aspx">http://www.microsoft.com/china/msdn/events/webcasts/shared/webcast/downloadarchive.aspx</A></P> <A
href="http://liujace.itpub.net/post/4284/240865">查看全文</A>
<P></P><BR style="CLEAR: both"></DIV>
<DIV class=contentcomments><A class=commentfoot
href="http://liujace.itpub.net/post/4284/240865#comments">评论 (0)</A> <A
class=commentfoot href="http://liujace.itpub.net/trackbacks/4284/240865">引用
(0)</A> <A class=commentfoot
href="http://liujace.itpub.net/category/4284/10421">手机编程[3]</A> <A
class=commentfoot href="http://liujace.itpub.net/category/4284/7950">技术资源[7]</A>
<A class=commentfoot
href="http://liujace.itpub.net/category/4284/7956">开源项目[1]</A> <A
class=commentfoot
href="http://liujace.itpub.net/category/4284/7955">C#编程[11]</A> <A
class=commentfoot
href="http://liujace.itpub.net/category/4284/42845">随心记事[0]</A> </DIV></DIV>
<DIV class=post><!-- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"><rdf:Description rdf:about="http://liujace.itpub.net/post/4284/240834" dc:identifier="http://liujace.itpub.net/post/4284/240834" dc:title="手机短信息的编解码类 -转" trackback:ping="http://blog.itpub.net//trackback.php?id=240834"/></rdf:RDF> -->
<DIV class=contenttitle><A
href="http://liujace.itpub.net/post/4284/240834">手机短信息的编解码类 -转</A></DIV>
<DIV class=contenttime>liujace - by - 14 十二月, 2006 22:00</DIV>
<DIV id=blogbody>
<P>
<P>//手机短信息的编解码类 <BR>//作者:未知 来源:转载 发布时间:2006-6-2 12:15:38 发布人:allman <BR>//减小字体
增大字体 </P>
<P>using System;<BR>using System.Text;</P>
<P>namespace jace.CN.SMSLib<BR>{<BR>/// <summary><BR>/// By popcorn
2004.5。<BR>/// <A
href="mailto:cnpopcorn@hotmail.com">cnpopcorn@hotmail.com</A><BR>///
</summary><BR>public class CNText<BR>{<BR>public CNText()<BR>{<BR>}
<BR>/// <summary><BR>/// 编码格式<BR>/// </summary><BR>public enum
GSMCode<BR>{<BR>Bit7=0,<BR>Bit8=1,<BR>UCS2=2<BR>}</P>
<P>/// <summary><BR>/// 对整个短信息进行解码<BR>/// </summary><BR>///
<param name="s">要解码的信息</param><BR>/// <param
name="phone">解码后的电话号码</param><BR>/// <param
name="text">解码后的短信内容</param><BR>/// <param
name="sendTime">短信时间戳</param><BR>/// <param
name="code">使用的编码方式</param><BR>/// <param
name="SCA">短信中心号</param><BR>///
<returns>成功返回true</returns><BR>static public bool DecodingMsg(string
s,ref string phone,ref string text,ref DateTime sendTime,ref GSMCode code,ref
string SCA)<BR>{<BR>try<BR>{<BR>//短信息中心<BR>int
iLength=int.Parse(s.Substring(0,2),System.Globalization.NumberStyles.AllowHexSpecifier);<BR>if(iLength>0)<BR>{<BR>if(s.Substring(2,2)=="91")<BR>{<BR>SCA+="+";<BR>iLength--;<BR>}<BR>for(int
i=0;i<iLength*2;i+=2)<BR>{<BR>SCA+=s.Substring(5+i,1);<BR>SCA+=s.Substring(4+i,1);<BR>}<BR>if(SCA.EndsWith("F"))SCA=SCA.Remove(SCA.Length-1,1);<BR>}</P>
<P>s=s.Remove(0,iLength*2+6);</P>
<P>//发送方号码<BR>iLength=int.Parse(s.Substring(0,2),System.Globalization.NumberStyles.AllowHexSpecifier);<BR>if(s.Substring(2,2)=="91")<BR>{<BR>phone="+";<BR>}
<BR>if(iLength%2==1)iLength++;<BR>for(int
i=0;i<iLength;i+=2)<BR>{<BR>phone+=s.Substring(5+i,1);<BR>phone+=s.Substring(4+i,1);<BR>}
<BR>if(phone.EndsWith("F"))phone=phone.Remove(phone.Length-1,1);</P>
<P>s=s.Remove(0,iLength+6);<BR>//编码方式<BR>if(s.Substring(0,2)=="08")<BR>code=GSMCode.UCS2;<BR>else
if(s.Substring(0,2)=="00")<BR>code=GSMCode.Bit7;<BR>else<BR>code=GSMCode.Bit8;</P>
<P>s=s.Remove(0,2);<BR>//时间戳<BR>sendTime=new
DateTime(int.Parse("20"+s.Substring(1,1)+s.Substring(0,1)),<BR>int.Parse(s.Substring(3,1)+s.Substring(2,1)),<BR>int.Parse(s.Substring(5,1)+s.Substring(4,1)),<BR>int.Parse(s.Substring(7,1)+s.Substring(6,1)),<BR>int.Parse(s.Substring(9,1)+s.Substring(8,1)),<BR>int.Parse(s.Substring(11,1)+s.Substring(10,1)));<BR>s=s.Remove(0,16);</P>
<P>//收到的信息<BR>if(code==GSMCode.Bit7)<BR>{<BR>text=DecodingBit7(s);<BR>}<BR>else
if(code==GSMCode.UCS2)<BR>{<BR>text=DecodingUCS2(s);<BR>}<BR>else<BR>{<BR>text=DecodingBit8(s);<BR>}<BR>return
true;<BR>}<BR>catch<BR>{<BR>return false;<BR>}<BR>}</P>
<P>/// <summary><BR>/// 对短信息中心进行编码<BR>/// </summary><BR>///
<param name="s">要编码的号码</param><BR>///
<returns>编码后的号码</returns><BR>static public string EncodingSCA(string
s)<BR>{<BR>StringBuilder sb=new
StringBuilder();<BR>if(s.Length==0)<BR>{<BR>sb.Append("00");<BR>return
sb.ToString();<BR>}<BR>if(s.StartsWith("+"))<BR>{<BR>sb.Append("91");
//用国际格式号码(在前面加‘+’)<BR>s=s.Remove(0,1);<BR>}<BR>else<BR>{<BR>sb.Append("C8");<BR>}<BR>if(s.Length%2==1)s+="F";<BR>for(int
i=0;i<s.Length;i+=2)<BR>{<BR>sb.Append(s.Substring(i+1,1));<BR>sb.Append(s.Substring(i,1));<BR>}<BR>string
len=(sb.Length/2).ToString("X2");<BR>return len+sb.ToString();<BR>}<BR>///
<summary><BR>/// 对电话号码进行编码<BR>/// </summary><BR>/// <param
name="mobileNo">要编码的电话号码</param><BR>///
<returns>编码后的电话号码</returns><BR>static public string
EncodingNumber(string mobileNo)<BR>{<BR>StringBuilder sb=new
StringBuilder();<BR>if(mobileNo.StartsWith("+"))<BR>{<BR>sb.Append("91");<BR>mobileNo=mobileNo.Remove(0,1);<BR>}<BR>else<BR>{<BR>sb.Append("C8");<BR>}<BR>string
len=mobileNo.Length.ToString("X2");<BR>if(mobileNo.Length%2==1)mobileNo+="F";<BR>for(int
i=0;i<mobileNo.Length;i+=2)<BR>{<BR>sb.Append(mobileNo.Substring(i+1,1));<BR>sb.Append(mobileNo.Substring(i,1));<BR>}<BR>return
len+sb.ToString();<BR>}</P>
<P>/// <summary><BR>/// 使用7-bit进行编码<BR>/// </summary><BR>///
<param name="s">要编码的英文字符串</param><BR>///
<returns>信息长度及编码后的字符串</returns><BR>static public string
EncodingBit7(string s)<BR>{<BR>int iLeft=0;<BR>string
sReturn="";<BR>StringBuilder sb=new StringBuilder();<BR>for(int
i=0;i<s.Length;i++)<BR>{<BR>// 取源字符串的计数值的最低3位<BR>int iChar = i & 7;
<BR>byte bSrc=(byte)char.Parse(s.Substring(i,1));<BR>// 处理源串的每个字节<BR>if(iChar ==
0)<BR>{<BR>// 组内第一个字节,只是保存起来,待处理下一个字节时使用<BR>iLeft =
(int)char.Parse(s.Substring(i,1));<BR>}<BR>else<BR>{<BR>//
组内其它字节,将其右边部分与残余数据相加,得到一个目标编码字节<BR>sReturn=(bSrc << (8-iChar) |
iLeft).ToString("X4");<BR>// 将该字节剩下的左边部分,作为残余数据保存起来<BR>iLeft = bSrc >>
iChar;<BR>// 修改目标串的指针和计数值 pDst++;<BR>sb.Append(sReturn.Substring(2,2));<BR>}
<BR>}<BR>sb.Append(sReturn.Substring(0,2));<BR>return
(sb.Length/2).ToString("X2")+sb.ToString();<BR>}<BR>/// <summary><BR>///
对7-bit编码进行解码<BR>/// </summary><BR>/// <param
name="s">要解码的字符串</param><BR>///
<returns>解码后的英文字符串</returns><BR>static public string
DecodingBit7(string s)<BR>{<BR>int iByte=0;<BR>int iLeft=0;<BR>//
将源数据每7个字节分为一组,解压缩成8个字节<BR>// 循环该处理过程,直至源数据被处理完<BR>//
如果分组不到7字节,也能正确处理<BR>System.Text.StringBuilder sb=new
System.Text.StringBuilder();<BR>for(int i=0;i<s.Length;i+=2)<BR>{<BR>byte
bSrc=byte.Parse(s.Substring(i,2),System.Globalization.NumberStyles.AllowHexSpecifier);<BR>//
将源字节右边部分与残余数据相加,去掉最高位,得到一个目标解码字节<BR>sb.Append((((bSrc << iByte) | iLeft)
& 0x7f).ToString("X2"));<BR>// 将该字节剩下的左边部分,作为残余数据保存起来<BR>iLeft = bSrc
>> (7-iByte);<BR>// 修改字节计数值<BR>iByte++;<BR>// 到了一组的最后一个字节<BR>if(iByte ==
7)<BR>{<BR>// 额外得到一个目标解码字节<BR>sb.Append(iLeft.ToString("X2")); <BR>//
组内字节序号和残余数据初始化<BR>iByte = 0;<BR>iLeft = 0;<BR>}<BR>}<BR>string
sReturn=sb.ToString();<BR>byte [] buf=new byte[sReturn.Length/2];<BR>for(int
i=0;i<sReturn.Length;i+=2)<BR>{<BR>buf[i/2]=byte.Parse(sReturn.Substring(i,2),System.Globalization.NumberStyles.AllowHexSpecifier);<BR>}<BR>return
System.Text.Encoding.ASCII.GetString(buf);<BR>}<BR>//[dvnews_page]<BR>///
<summary><BR>/// 使用8-bit进行编码<BR>/// </summary><BR>/// <param
name="s">要编码的字符串</param><BR>///
<returns>信息长度及编码后的字符串</returns><BR>static public string
EncodingBit8(string s)<BR>{<BR>StringBuilder sb=new StringBuilder();<BR>byte []
buf=Encoding.ASCII.GetBytes(s);<BR>sb.Append(buf.Length.ToString("X2"));<BR>for(int
i=0;i<buf.Length;i++)<BR>{<BR>sb.Append(buf[i].ToString("X2"));<BR>}<BR>return
sb.ToString();<BR>}<BR>/// <summary><BR>/// 使用8-bit进行解码<BR>///
</summary><BR>/// <param name="s">要解码的字符串</param><BR>///
<returns>解码后的字符串</returns><BR>static public string
DecodingBit8(string s)<BR>{<BR>byte [] buf=new
byte[s.Length/2];<BR>StringBuilder sb=new StringBuilder();<BR>for(int
i=0;i<s.Length;i+=2)<BR>{<BR>buf[i/2]=byte.Parse(s.Substring(i,2),System.Globalization.NumberStyles.AllowHexSpecifier);<BR>}<BR>return
Encoding.ASCII.GetString(buf);<BR>}</P>
<P>/// <summary><BR>/// 中文短信息UCS2编码<BR>/// </summary><BR>///
<param name="s">要编码的中文字符串</param><BR>///
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -