C#版
public String UrlEncode(String content)
{
StringBuilder sBuilder = new StringBuilder();
byte[] byStr = System.Text.Encoding.UTF8.GetBytes(content);
for (int i = 0; i < byStr.Length; i++)
{
sBuilder.Append(@"%" + Convert.ToString(byStr[i], 16));
}
return sBuilder.ToString();
}