2012-12-07 38 views
1

我的頁面上我已經設置了UTF-8編碼。然後,我發送encodeURIComponent()函數編碼的字符串「ły」到%C5%82y並在服務器端,我得到%25C5%2582y。現在我想回到原來的字符串。C#如何從UTF-8字符串中檢索原始字符串?

我已經試過:

HttpUtility.HtmlDecode(): the result is %25C5%2582y 
Uri.UnescapeDataString(): the result is %C5%82y 

我現在很困惑 - 如何檢索回原始字符串?

+0

如何從encodeURIComponent中獲得#C5y#82y? – deceze

+0

我認爲這是你在找什麼: http://stackoverflow.com/questions/86477/does-c-sharp-have-an-equivalent-to-javascripts-encodeuricomponent –

+0

這看起來像一個雙 - 編碼,其中'%C5'中的'%'編碼爲'%25'。 – wberry

回答

0
Uri.UnescapeDataString(HttpUtility.UrlDecode("ły")); 

做的伎倆

+0

你可能也可以做任何兩次,比如'Uri.UnescapeDataString(Uri.UnescapeDataString(「%25C5%2582y」))''。 –

1

使用HttpUtility.UrlEncode編碼和HttpUtility.UrlDecode解碼。

相關問題