Forum Moderators: coopster

Message Too Old, No Replies

How to handle special characters in get data

         

andrewsmd

4:08 pm on Dec 7, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I take input from a text box and pass it to a php file using ajax as get data. I've noticed that I have some issues with special characters break my input i.e. a # or &. While that makes sense as to why the break the system. I'm wondering on how I should handle these? Any thoughts?

jdMorgan

4:58 pm on Dec 7, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"Special characters" must be URL-encoded for transmission in either direction.

The definition of "special" changes depending on where in the request line the character occurs; the "rules" for the URL-path, the query string, and the URL-fragment differ.

More info in RFC2396 - Uniform Resource Identifiers (URI): Generic Syntax [faqs.org].

Modern scripting languages support URL-encoding and URL-decoding with built-in functions having names similar to "URL encode" and "URL decode."

Jim