Windows Phone 7 中具有特定编码的 UrlEncode?
在“常规”.NET 中,有一个 UrlEncode 方法,它采用 Encoding范围。 有没有这样的 WP7.NET 中的 UrlEncode 方法?
我位于瑞典,我正在尝试从 REST 服务检索数据,该服务期望请求中包含 ISO-8859-1(但以 UTF-8 进行响应)。 当进行搜索(input=frölunda
)并仅使用 UrlEncode 时,我得到 input=fr%C3%B6lunda
,由于“丢失”ö,它返回非常奇怪的结果。 使用带有 iso-8859-1 编码的 .NET UrlDecode 我得到 input=fr%F6lunda
,它返回预期的结果。
我必须实现自己的 UrlEncode 吗?
In "regular" .NET there is a UrlEncode method that takes an Encoding parameter.
Is there no such UrlEncode method in .NET for WP7?
I'm located in Sweden and I'm trying to retrieve data from a REST service that expects ISO-8859-1 in the requests (but responds in UTF-8).
When doing a search (input=frölunda
) and just using UrlEncode i get input=fr%C3%B6lunda
which returns very strange results because of the "missing" ö.
Using the .NET UrlDecode with iso-8859-1 encoding i get input=fr%F6lunda
which returns the excpected results.
Do I have to implement my own UrlEncode?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有趣的是,微软似乎正在通过 Silverlight 遵循这一标准。 维基百科 说:
所以看起来他们放弃了编码的选择,因为无论如何只允许一种。
除此之外,您并不是唯一遇到此问题的人。建议是:不要重新发明轮子,使用已经编写的代码来获取您需要的 HtmlEncode。 (除了建议使用
Uri.EscapeUriString
而不是客户端的HttpUtility.UrlEncode
- 但我无法判断。)Interesting, it seems like Microsoft is following the standard here with Silverlight. Wikipedia says:
So it seems like they dropped the choice of encoding since only one is allowed anyway.
Apart from that you are not the only one having this problem. The recommendation there is: don't reinvent the wheel and use code already written to get the HtmlEncode you need. (Apart from the recommendation to use
Uri.EscapeUriString
instead ofHttpUtility.UrlEncode
on the client side - but I can't judge that.)