c# - Windows Phone 7 中具有特定编码的 UrlEncode?

标签 c# windows-phone-7 iso-8859-1

在“常规”.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/

相关文章:

c# - 使用 Linq 获取每个客户昨天下的最后一个订单

c# - 对 LockBits、BitmapData 和 PixelFormat.Format48bppRgb 感到困惑

php - ___ 编码为 UTF-8 - 是否有最终解决方案?

java - 如何从以 latin1 编码的结果集中以 UTF-8 编码字符串

c++ - 将字符串从 UTF-8 转换为 ISO-8859-1

c# - 从外部服务器获取图像

C# WebBrowser 禁用和隐藏滚动条

c# - 如何使用 MVVM 在 WP7 中聚焦文本框?

windows-phone-7 - 获取当前播放的歌曲列表 Windows Phone 7

c# - 如何检查用户是否连接到互联网 wp7 ?