2012年1月4日 星期三

C# UrlEncode To Uppercase

http://stackoverflow.com/questions/918019/net-urlencode-lowercase-problem

public static string UpperCaseUrlEncode(string s)
{
char[] temp = HttpUtility.UrlEncode(s).ToCharArray();
for (int i = 0; i < temp.Length - 2; i++)
{
if (temp[i] == '%')
{
temp[i + 1] = char.ToUpper(temp[i + 1]);
temp[i + 2] = char.ToUpper(temp[i + 2]);
}
}
return new string(temp);
}

沒有留言:

張貼留言