private void EncodeName(string str)
{
string strGB2312=System.Web.HttpUtility.UrlEncode(str,System.Text.Encoding.GetEncoding("GB2312")).ToUpper();
string DecodeGB2312=System.Web.HttpUtility.UrlDecode(strGB2312,System.Text.Encoding.GetEncoding("GB2312"));
// System.Text.Encoding.Default 默认编码
Response.Write( "编码(GB2312):"+ strGB2312 +"<br>" );
Response.Write( "解码(GB2312):"+ DecodeGB2312 +"<p></p>" );
string EncodeNameUTF8=System.Web.HttpUtility.UrlEncode(str,System.Text.Encoding.GetEncoding("utf-8")).ToUpper();
string DecodeUTF8=System.Web.HttpUtility.UrlDecode(EncodeNameUTF8,System.Text.Encoding.GetEncoding("utf-8"));
Response.Write( "编码(UTF8):"+ strEncodeNameUTF8 +"<br>" );
Response.Write( "解码(UTF8):"+ DecodeUTF8 +"<br>" );
}
{
string strGB2312=System.Web.HttpUtility.UrlEncode(str,System.Text.Encoding.GetEncoding("GB2312")).ToUpper();
string DecodeGB2312=System.Web.HttpUtility.UrlDecode(strGB2312,System.Text.Encoding.GetEncoding("GB2312"));
// System.Text.Encoding.Default 默认编码
Response.Write( "编码(GB2312):"+ strGB2312 +"<br>" );
Response.Write( "解码(GB2312):"+ DecodeGB2312 +"<p></p>" );
string EncodeNameUTF8=System.Web.HttpUtility.UrlEncode(str,System.Text.Encoding.GetEncoding("utf-8")).ToUpper();
string DecodeUTF8=System.Web.HttpUtility.UrlDecode(EncodeNameUTF8,System.Text.Encoding.GetEncoding("utf-8"));
Response.Write( "编码(UTF8):"+ strEncodeNameUTF8 +"<br>" );
Response.Write( "解码(UTF8):"+ DecodeUTF8 +"<br>" );
}