Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

replace special characters to original character?

Status
Not open for further replies.

GoSooJJ

Programmer
Feb 24, 2001
76
US
I'm having little hard time to figure out how to replace URL encoded characters to original characters. For example I have this cookie from Coldfusion and it displays:

SESSION_INFO=12345%7C%7C1%7C%7C123%7C%7C10%2E6;
which is 12345||1||123||10.6

Can anyone show me how to convert SESSION_INFO to 12345||1||123||10.6?
 
Parse the string and every time you find a %, take the next two characters and convert them from a hex number to their proper ASCII value. Everything else should be a literal value.
Ex. 0x7C is the '|' symbol and 0x2E is the '.' symbol.

To convert from hex to decimal you can use sprintf() or you can use stringstream.
You'll also need to convert the decimal number to a character. The easiest way would be to just cast it to a char.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top