- Home /
WWW form string data: best way to encode/escape string data?
I'm collecting strings from users which I need to store in an online database.
Just sending a string as-is is problematic of course. ex: "This isn't just quoted, it's "double quoted" "
And that's just quote! Not to mention & < > \ etc.
So, shoud I use WWW.EscapeURL (which seems to be URL-centric, rather than arbitrary string centric), or is there a handy System function for doing this? And the reverse of this in PHP, too, as sometimes they behave non-symetrically ;)
(System.Web.HttpUtility.HtmlEncode/.Decode seem unavailable. This will be a web-browser app btw).
Answer by Art 1 · Feb 01, 2011 at 12:22 AM
var sendMe = yourstring.Replace("&", "& amp ;").Replace("<", & lt ;").Replace(">",& gt ;").Replace("\"", "& quot ;");
I was hoping for something 'cleaner', like a library call. This will work in a pinch though, thanks
Your answer
Follow this Question
Related Questions
How do I properly send binary data (byte[]) to a MySQL database? 4 Answers
How to debug php code when use www to communicate with server side. 0 Answers
How to save screenshots from webplayer on the fly via JSP-script to the users disk? 0 Answers
Question about screenshots and facebook integration 1 Answer