UrlDecode

From CometWiki

Revision as of 19:23, 3 June 2016 by Jim (Talk | contribs)
Jump to: navigation, search

Changes characters which were encoded by the browser to their ascii equivalents...

void URLdecode(CString &Value)
{
	Value.Replace(_T("""),_T("\""));        
	Value.Replace(_T("<"  ),_T("<"));        
	Value.Replace(_T(">"  ),_T(">"));        
	Value.Replace(_T("&" ),_T("&"));        
	Value.Replace(_T(" "),_T(" "));        
	Value.Replace(_T("+"),_T(" "));
	CString a;
	CString b;
	for (int i=0;i<=255;i++)
	{
		char x = i;
		CString b = x;
		a.Format("&#%d;",i);
		Value.Replace(a,b);
		a.Format("%%%02X",i);
		Value.Replace(a,b);
		a.Format("%%%02x",i);
		Value.Replace(a,b);
	}
}
Personal tools