views:

442

answers:

1

I have an app that uses ajax (jQuery) 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?

+1  A: 

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

Doug D
Cheers that sorted it https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Functions/encodeURIComponent and then I used the fixedEncodeURIComponent function they describe near the bottom.
Gazeth