網址編碼轉換
含有中文的網址中顯示百分號%等亂碼是什麼?
我們有時候下載的網址不是英文的話 會變成像http://www194.megaupload.com/files/5ce1a9987977f843349b47e321853f12/%E4%BB%BB%E5%A4%A9%E5%A0%82%E5%A4%A7%E4%BA%82%E9%AC%A5Nin64tendo%20All-Star!%20Dairantou%20Smash%20Brothers%20(J).rar
這樣的亂碼,但這網址原本是中文的,可以利用HttpUtility.UrlDecode 把網址轉回正常的中文
以下是範例code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Web;
namespace WindowsFormsApplication1
{
public partial class Decode : Form
{
public Decode()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox2.Text = HttpUtility.UrlDecode(textBox1.Text);
}
}
}
如有錯誤 歡迎指正