UrlDecode

From CometWiki

(Difference between revisions)
Jump to: navigation, search
(initial page)
 
(2 intermediate revisions not shown)
Line 1: Line 1:
Changes characters which were encoded by the browser to their ascii equivalents...
Changes characters which were encoded by the browser to their ascii equivalents...
 +
 +
A$ = urldecode(a$)
 +
 +
<pre>
<pre>
-
void URLdecode(CString &Value)
+
  "&amp;quot;"         decodes to """
-
{
+
  "&amp;apos;"          decodes to "'"     
-
Value.Replace(_T("&quot;"),_T("\""));      
+
  "&amp;lt;"     decodes to "<"    
-
Value.Replace(_T("&lt;" ),_T("<"));       
+
  "&amp;gt;"     decodes to ">"    
-
Value.Replace(_T("&gt;" ),_T(">"));       
+
  "&amp;amp;"     decodes to "&"    
-
Value.Replace(_T("&amp;" ),_T("&"));       
+
  "&amp;nbsp;"     decodes to " "    
-
Value.Replace(_T("&nbsp;"),_T(" "));       
+
  "+"     decodes to " "
-
Value.Replace(_T("+"),_T(" "));
+
  "%3B"            decodes to  ";"
-
CString a;
+
  "%3F"            decodes to  "?"
-
CString b;
+
  "%2F"            decodes to  "/"
-
for (int i=0;i<=255;i++)
+
  "%3A"            decodes to  ":"
-
{
+
  "%23"            decodes to  "#"
-
char x = i;
+
  "%26"            decodes to  "&"
-
CString b = x;
+
  "%3D"            decodes to  "="
-
a.Format("&#%d;",i);
+
  "%2B"            decodes to  "+"
-
Value.Replace(a,b);
+
  "%24"            decodes to  "$"
-
a.Format("%%%02X",i);
+
  "%2C"            decodes to  ","
-
Value.Replace(a,b);
+
  "%20" or "+"      decodes to  "<space>"
-
a.Format("%%%02x",i);
+
  "%25"            decodes to  "%"
-
Value.Replace(a,b);
+
  "%3C"            decodes to  "<"
-
}
+
  "%3E"            decodes to  ">"
-
}
+
  "%7E"            decodes to  "~"
 +
  "%25"             decodes to  "%"
 +
  Note that because the <space> character is very commonly used, a special code ( the "+" sign)  
 +
  has been reserved as its URL encoding.
 +
  Thus the string "A B" can be URL encoded as either "A%20B" or "A+B".
 +
 
 +
 +
 
</pre>
</pre>

Latest revision as of 16:31, 8 June 2016

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

A$ = urldecode(a$)


  "&quot;"          decodes to """
  "&apos;"          decodes to "'"       
  "&lt;"  	    decodes to "<"      
  "&gt;"  	    decodes to ">"      
  "&amp;" 	    decodes to "&"      
  "&nbsp;"	    decodes to " "      
  "+"		    decodes to " "
  "%3B"             decodes to  ";"	
  "%3F"             decodes to  "?"	
  "%2F"             decodes to  "/"	
  "%3A"             decodes to  ":"	
  "%23"             decodes to  "#"	
  "%26"             decodes to  "&"	
  "%3D"             decodes to  "="	
  "%2B"             decodes to  "+"	
  "%24"             decodes to  "$"	
  "%2C"             decodes to  ","	
  "%20" or "+"      decodes to  "<space>"
  "%25"             decodes to  "%"
  "%3C"             decodes to  "<"
  "%3E"             decodes to  ">"
  "%7E"             decodes to  "~"
  "%25"             decodes to  "%"
   Note that because the <space> character is very commonly used, a special code ( the "+" sign) 
   has been reserved as its URL encoding.  
   Thus the string "A B" can be URL encoded as either "A%20B" or "A+B".

 

Personal tools