在“常规”.NET 中有一个 UrlEncode采用编码参数的方法。 有没有这个UrlEncode .NET 中用于 WP7 的方法?
我位于瑞典,我正在尝试从 REST 服务检索数据,该服务要求请求中包含 ISO-8859-1(但以 UTF-8 响应)。
在进行搜索 (input=frölunda
) 并仅使用 UrlEncode 时,我得到了 input=fr%C3%B6lunda
,由于“缺少”ö,它会返回非常奇怪的结果。
使用带有 iso-8859-1 编码的 .NET UrlDecode 我得到 input=fr%F6lunda
返回预期的结果。
我必须实现自己的 UrlEncode 吗?
最佳答案
有趣的是,Microsoft 似乎正在遵循 Silverlight 的标准。 Wikipedia说:
[...] should convert all other characters to bytes according to UTF-8, and then percent-encode those values. This requirement was introduced in January 2005 with the publication of RFC 3986. URI schemes introduced before this date are not affected.
所以他们似乎放弃了编码的选择,因为无论如何只允许一个。
除此之外,你不是唯一一个having this problem .那里的建议是:不要重新发明轮子和use code already written获得你需要的 HtmlEncode。 (除了建议在客户端使用 Uri.EscapeUriString
而不是 HttpUtility.UrlEncode
- 但我无法判断。)
关于c# - Windows Phone 7 中具有特定编码的 UrlEncode?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8464479/