易截截图软件、单文件、免安装、纯绿色、仅160KB

c#短信网关中关于短信内容编码的转换

无论在cmpp或sgip中,都会遇到短信编码格式转换的问题。
因为现在短信编码常用的格式有三种:0:ASCII串,8:UCS2编码,15:含GB汉字。在发送或接收短信时,都会用到相应的编码转换。如以下代码:
public static String Decode(Byte[] buf, int StartIndex, int Length, CODING Coding)
{
String str = String.Empty;
if (Coding == CODING.ASCII)
str = System.Text.Encoding.ASCII.GetString(buf, StartIndex, Length);
else if (Coding == CODING.UCS2)
str = System.Text.Encoding.BigEndianUnicode.GetString(buf, 0, Length);
else if (Coding == CODING.GBK)
str = System.Text.UnicodeEncoding.GetEncoding("gb2312").GetString(buf, StartIndex, Length);
return str;
}
public static Byte[] Encode(String str, CODING coding)
{
Byte[] buf = null;
if (str == null)
return buf;
if (coding == CODING.ASCII)
buf = System.Text.Encoding.ASCII.GetBytes(str);
else if (coding == CODING.UCS2)
buf = System.Text.Encoding.BigEndianUnicode.GetBytes(str);
else if (coding == CODING.GBK)
buf = System.Text.UnicodeEncoding.GetEncoding("gb2312").GetBytes(str);
return buf;
}
public static UInt32 CountLength(String str, CODING coding)
{
Byte[] buf = Encode(str, coding);
if (buf != null)
return (UInt32)buf.Length;
else
return 0;
}
在处理接收DELIVER时,也可以这样写
if (Msg_Fmt != 8)
{
if (Msg_Fmt != 15)
{
this.Msg_Content = System.Text.Encoding.ASCII.GetString(buffer, iPos, (int)this.Msg_Length);
}
else
{
this.Msg_Content = Syst


相关文档:

java的Qname在C#中对应的是什么

首先了解一下什么是Qname
下面是一篇写的比较好的关于Qname的介绍:
http://blog.csdn.net/fbysss/archive/2007/06/24/1664076.aspx
可见Qname主要是处理namesapce的,是指具有特定前缀的xml element。而且Qname就是QualifiedName的缩写,所以Qname在C#中对应的应该是XmlQualifiedName这个类 ......

c#中调用JavaScript脚本函数的一种方法

利用            Page.RegisterStartupScript("", "<script language='javascript'> results();</script>");    
      或者是         Page.RegisterClient ......

搜索之路 c#从html中提取文本

直接封装成一个类的,用起来还挺方便的
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text ......

asp.net c# 服务器端各绑定控件常用

asp.net有时候常常用服务器绑定控件有些麻烦...
代码有些杂....
using System;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.Web;
using System.Text;
namespace pub.mo
{
public class bind
{
p ......

C# post表单

2010这个元旦太无聊了,于是找了个奇迹游戏私服耍,在玩的过程中发现总是要登录到网站上去转生加点之类的操作,1次2次还好,100次你就郁闷了,于是自己想写个简单的程序来做。
以下就是代码部分啦:
(需要注意的是WebClient的Cookie部分)
using System;
using System.Collections.Generic;
using System.ComponentMo ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号