[我的ASP.net学习历程]编码转换http://www.21tx.com/dev/2004/09/21/12011.html
来源:互联网 发布:mac日历邀请怎么删除 编辑:程序博客网 时间:2024/06/05 10:24
<%@ Page Language="C#" AutoEventWireup="True" Debug="true" ValidateRequest="false" %>
<Script language="C#" runat="server">
void Page_Load(Object Sender,EventArgs e){
if (!Page.IsPostBack){
Response.Write("还没有输入任何字符!<br><br>");
}
else{
Label_1.Text="";
Label_2.Text="";
Label_0.Text=Convert.ToString((TextBox_1.Text).Length);
//ASCII编码输出
ByteFunction(TextBox_1.Text);
//字符码输出
CharFunction(TextBox_1.Text);
//HTML编码输出
HtmlFunction(TextBox_1.Text);
}
}
//ASCII编码输出函数
void ByteFunction(string str){
Byte[] MyBytes=System.Text.Encoding.ASCII.GetBytes(str);
for (int i=0;i<str.Length;i++){
Label_2.Text+=Convert.ToString(MyBytes[i])+" ";
}
}
//字符码输出函数
void CharFunction(string str){
Byte[] MyBytes=System.Text.Encoding.ASCII.GetBytes(str);
Char[] MyChars=System.Text.Encoding.ASCII.GetChars(MyBytes);
//Label_2.Text=new string(MyChars);
for (int i=0;i<str.Length;i++){
Label_1.Text+=Convert.ToString(MyChars[i])+" ";
}
}
//HTML编码输出函数
void HtmlFunction(string str){
string Str_Html=(Server.HtmlEncode(str));
Label_3.Text=Str_Html;
Label_4.Text=Server.HtmlEncode(Str_Html);
}
</Script>
<form runat="server">
请输入字符串:
<ASP:TextBox ID="TextBox_1" runat="server"/>
<asp:button ID="Button_1" Text="提交" runat="server"/>
</form>
您输入的字符串长度:
<asp:label ID="Label_0" runat="server"/><br>
字符码为:
<asp:label ID="Label_1" runat="server"></asp:label><br>
ASCII码编码:
<asp:label ID="Label_2" runat="server"></asp:label><br>
HTML编码为:
<asp:label ID="Label_3" runat="server"></asp:label><br>
HTML编码以字符输出:
<asp:label ID="Label_4" runat="server"/><br>
<Script language="C#" runat="server">
void Page_Load(Object Sender,EventArgs e){
if (!Page.IsPostBack){
Response.Write("还没有输入任何字符!<br><br>");
}
else{
Label_1.Text="";
Label_2.Text="";
Label_0.Text=Convert.ToString((TextBox_1.Text).Length);
//ASCII编码输出
ByteFunction(TextBox_1.Text);
//字符码输出
CharFunction(TextBox_1.Text);
//HTML编码输出
HtmlFunction(TextBox_1.Text);
}
}
//ASCII编码输出函数
void ByteFunction(string str){
Byte[] MyBytes=System.Text.Encoding.ASCII.GetBytes(str);
for (int i=0;i<str.Length;i++){
Label_2.Text+=Convert.ToString(MyBytes[i])+" ";
}
}
//字符码输出函数
void CharFunction(string str){
Byte[] MyBytes=System.Text.Encoding.ASCII.GetBytes(str);
Char[] MyChars=System.Text.Encoding.ASCII.GetChars(MyBytes);
//Label_2.Text=new string(MyChars);
for (int i=0;i<str.Length;i++){
Label_1.Text+=Convert.ToString(MyChars[i])+" ";
}
}
//HTML编码输出函数
void HtmlFunction(string str){
string Str_Html=(Server.HtmlEncode(str));
Label_3.Text=Str_Html;
Label_4.Text=Server.HtmlEncode(Str_Html);
}
</Script>
<form runat="server">
请输入字符串:
<ASP:TextBox ID="TextBox_1" runat="server"/>
<asp:button ID="Button_1" Text="提交" runat="server"/>
</form>
您输入的字符串长度:
<asp:label ID="Label_0" runat="server"/><br>
字符码为:
<asp:label ID="Label_1" runat="server"></asp:label><br>
ASCII码编码:
<asp:label ID="Label_2" runat="server"></asp:label><br>
HTML编码为:
<asp:label ID="Label_3" runat="server"></asp:label><br>
HTML编码以字符输出:
<asp:label ID="Label_4" runat="server"/><br>
- [我的ASP.net学习历程]编码转换http://www.21tx.com/dev/2004/09/21/12011.html
- 动态的管理ASP.NET DataGrid数据列(转自:http://dev.21tx.com)
- http://dev.21tx.com/dotnet/csharp/index_8.html
- [我的ASP.net学习历程]编码转换
- [ASP.net]URL重写续篇 http://www.cnblogs.com/hd/archive/2005/06/21/178367.html
- [我的ASP.net学习历程]类型转换
- http://www.soaspx.com/dotnet/asp.net/tech/tech_20100928_5785.html
- ASP.net的RUL重写http://www.cnblogs.com/hd/archive/2005/06/20/177633.html
- ASP.NET中存取图片到数据库的示例(转载http://www.knowsky.com/3257.html)
- [我的ASP.net学习历程]DropDownList
- [我的ASP.net学习历程]IsPostBack
- [我的ASP.net学习历程]out
- [我的ASP.net学习历程]Reference
- [我的ASP.net学习历程]RegularExpressionValidator
- http://www.cnblogs.com/hadoop-dev/p/6908660.html
- http://www.itwis.com/html/net/c/
- 我的学习资源-----我的网盘---http://www.yimuhe.com/u/franklin1990-0-1.html
- asp.net的postback机制 (转自http://www.cnblogs.com/KenBlove/archive/2008/11/06/1328238.html)
- WINDOWS 蓝屏错误代码说明一览表
- 国庆is coming...
- javascript小技巧
- Wii和我的游戏心情
- Win2000蓝屏STOP故障现象解析
- [我的ASP.net学习历程]编码转换http://www.21tx.com/dev/2004/09/21/12011.html
- 游戏外挂设计技术探讨
- Web2.0的商业模式:网络社区与嵌入式营销
- NickLee.FortuneJava(2007.2) for Vs.net2005 SP1、mainsoft、Java、Linux
- 转 匈牙利命名法
- 教你深入了解2000//XP蓝屏,及解决方法。
- ASP.NET图形化的曲线图类
- MSSQL安装的麻烦
- 感时花溅泪