开发者

URL Decoding JSON in C#

开发者 https://www.devze.com 2022-12-18 12:49 出处:网络
I have an app that uses ajax (jQ开发者_StackOverflow社区uery) quite extensively and when sending JSON to my web service I always \"escape\" any strings to make sure there is not any nastiness in there

I have an app that uses ajax (jQ开发者_StackOverflow社区uery) quite extensively and when sending JSON to my web service I always "escape" any strings to make sure there is not any nastiness in there. To decode it at the other end (in my c# code) I have been using HttpUtility.URLDecode() and this has been working a treat until it came to the £ symbol, it just doesn't seem to be able to handle it.

What I want to know is, is this the best way of decoding my strings and how do I go about handling the £ sign?


The problem may be on the escaping side. Use JavaScript's encodeURIComponent(), not the older escape(), which doesn't handle Unicode characters as well.


I had the same problem, the problem was escape().

To retrieve data in C# i use System.Uri.UnescapeDataString()

0

精彩评论

暂无评论...
验证码 换一张
取 消