1 / 6

URL Encoding

URL Encoding. When data is entered on a Web page form, it must be encoded before it can be passed to some program for processing. Each element on the form has a name (key), and a value. Data is represented by a key-value pair. For example, a field representing age with a value of 30, would

Thomas
Download Presentation

URL Encoding

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. URL Encoding When data is entered on a Web page form, it must be encoded before it can be passed to some program for processing. Each element on the form has a name (key), and a value. Data is represented by a key-value pair. For example, a field representing age with a value of 30, would appear in the input stream as: age=30

  2. URL Encoding Rules • Each key-value pair is separated by the ampersand (&) character. • Spaces are replaced with the plus sign (+) character. • All other special characters are replaced with their hexadecimal equivalent, in the form %nn. A response of 01/22/2001 for today’s date would be: today=01%2F22%2F2001 since %2F is the hexadecimal equivalent of the slash (/) character.

  3. Write a C++ program to parse a character string, as received from a web browser, into its component parts. Following is a sample form, the resulting encoded string, and the desired output. You should label and split the key-value pairs as shown. Assume you have the character string available in a file called testData.txt. Don’t worry about the form itself, it is just for reference. Don’t worry about the names of the elements (the keys) I used T1,T2,T3,S1,S2,S3 and B1 in my example. This is simply a character string processing problem. All you need to know are the encoding rules!

  4. testData.txt (This is what is passed to the parsing program) T1=A+New+Student&T3=Myhome@AnytownUSA&T2=10-123-9898&S1=CIS111%2C+CIS115+%28The+Internet%29%2C+MAT100&S2=I+need+it+for+my+degree.&S3=I+am+interested+in+anything+to+do+with+the+Internet%21%21%0D%0AWill+there+be+many+programs+to+write+in+this+course%3F&B1=Submit

  5. field name: T1 field content: A New Student field name: T3 field content: Myhome@AnytownUSA field name: T2 field content: 10-123-9898 field name: S1 field content: CIS111, CIS115 (The Internet), MAT100 field name: S2 field content: I need it for my degree. field name: S3 field content: I am interested in anything to do with the Internet!! Will there be many programs to write in this course? field name: B1 field content: Submit Press any key to continue

More Related