怎么把一个汉字转换为URLEncode格式,而不是用URLEncode()
解决方案 »
- 新手关于PDF问题,请大家进来看看,帮帮忙,谢谢了
- URL重写
- Response.Write("<script language='javascript'>window.open('考试.aspx','desktop','fullscreen=1,scrollbars=yes')</script>"); 在客户端窗口怎
- vs 2008 问题
- 紧急求助:SQL Server2000服务器突然连接不上了
- 一定要安装SQL Server Express ?
- 绝对实用!! 关于NHibernate 的用法!高手指点!
- 在模式窗口用ReportViewer打印展现reporting Server中的远程报表时出现错误
- 问个三层的问题
- treeview在绑定xml后,selectednodeIndex不起作用了?为什么?
- 超级无敌 菜鸟问题
- 如何获取MSSQL存储过程中返回的多个结果集?
你可以在javascript里用encodeURLComponent或者enscape
添加引用即可!
另
反编译HttpServerUtility.UrlEncode
后面是逐层调用的方法public string UrlEncode(string s)
{
Encoding encoding1 = (this._context != null) ? this._context.Response.ContentEncoding : Encoding.UTF8;
return HttpUtility.UrlEncode(s, encoding1);
}public static string UrlEncode(string str, Encoding e)
{
if (str == null)
{
return null;
}
return Encoding.ASCII.GetString(HttpUtility.UrlEncodeToBytes(str, e));
}
public static byte[] UrlEncodeToBytes(string str, Encoding e)
{
if (str == null)
{
return null;
}
byte[] buffer1 = e.GetBytes(str);
return HttpUtility.UrlEncodeBytesToBytesInternal(buffer1, 0, buffer1.Length, false);
}
private static byte[] UrlEncodeBytesToBytesInternal(byte[] bytes, int offset, int count, bool alwaysCreateReturnValue)
{
int num1 = 0;
int num2 = 0;
for (int num3 = 0; num3 < count; num3++)
{
char ch1 = (char) bytes[offset + num3];
if (ch1 == ' ')
{
num1++;
}
else if (!HttpUtility.IsSafe(ch1))
{
num2++;
}
}
if ((!alwaysCreateReturnValue && (num1 == 0)) && (num2 == 0))
{
return bytes;
}
byte[] buffer1 = new byte[count + (num2 * 2)];
int num4 = 0;
for (int num5 = 0; num5 < count; num5++)
{
byte num6 = bytes[offset + num5];
char ch2 = (char) num6;
if (HttpUtility.IsSafe(ch2))
{
buffer1[num4++] = num6;
}
else if (ch2 == ' ')
{
buffer1[num4++] = 0x2b;
}
else
{
buffer1[num4++] = 0x25;
buffer1[num4++] = (byte) HttpUtility.IntToHex((num6 >> 4) & 15);
buffer1[num4++] = (byte) HttpUtility.IntToHex(num6 & 15);
}
}
return buffer1;
}
那咋整...
我想问,能不能可以通过编码格式来产生,ENCODING类