encodeURIComponent ColdFusion

May 17, 2010 at 1:01 am Leave a comment


JavaScript encodeURIComponent converted to ColdFusion. This is used for OAuth.

			
 <cffunction 
 access="private" 
 name="doPercentEncode" 
 output="false" 
 returntype="string">

 <cfargument 
 name="stringToEncode" 
 type="string" 
 required="yes">

 <cfscript>
 variables.encodedString = arguments.stringToEncode;
 variables.encodedString = replace( variables.encodedString, "!", "%21", "all" );
 variables.encodedString = replace( variables.encodedString, "*", "%2A", "all" );
 variables.encodedString = replace( variables.encodedString, "##", "%23", "all" );
 variables.encodedString = replace( variables.encodedString, "$", "%24", "all" );
 variables.encodedString = replace( variables.encodedString, "%", "%25", "all" );
 variables.encodedString = replace( variables.encodedString, "&", "%26", "all" );
 variables.encodedString = replace( variables.encodedString, "'", "%27", "all" );
 variables.encodedString = replace( variables.encodedString, "(", "%28", "all" );
 variables.encodedString = replace( variables.encodedString, ")", "%29", "all" );
 variables.encodedString = replace( variables.encodedString, "@", "%40", "all" );
 variables.encodedString = replace( variables.encodedString, "/", "%2F", "all" );
 variables.encodedString = replace( variables.encodedString, "^", "%5E", "all" );
 variables.encodedString = replace( variables.encodedString, "~", "%7E", "all" );
 variables.encodedString = replace( variables.encodedString, "{", "%7B", "all" );
 variables.encodedString = replace( variables.encodedString, "}", "%7D", "all" );
 variables.encodedString = replace( variables.encodedString, "[", "%5B", "all" );
 variables.encodedString = replace( variables.encodedString, "]", "%5D", "all" );
 variables.encodedString = replace( variables.encodedString, "=", "%3D", "all" );
 variables.encodedString = replace( variables.encodedString, ":", "%3A", "all" );
 variables.encodedString = replace( variables.encodedString, ",", "%2C", "all" );
 variables.encodedString = replace( variables.encodedString, ";", "%3B", "all" );
 variables.encodedString = replace( variables.encodedString, "?", "%3F", "all" );
 variables.encodedString = replace( variables.encodedString, "+", "%2B", "all" );
 variables.encodedString = replace( variables.encodedString, "\", "%5C", "all" );
 variables.encodedString = replace( variables.encodedString, '"', "%22", "all" );
 return variables.encodedString;
 </cfscript>

 </cffunction>
Advertisements

Entry filed under: ColdFusion, JavaScript.

Pacific Fox web directory Accommodation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 19 other followers

Archives

Top Rated

Top Clicks

  • None

Blog Stats

  • 168,382 hits

%d bloggers like this: