2012-12-07 37 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解码。

相关问题