• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How do I encode these special characters?

Contributor ,
Feb 24, 2008 Feb 24, 2008

Copy link to clipboard

Copied

I am amazed that I cannot find any examples of how to do this (so far). Basically, I need to URL encoded only these special characters, as specified in RFC1738, section 2.2:

";","/", "?", ":", "@", "=" and "&" (plus "+" although "+" is not required by section 2.2)

I find it strange that thers is no URLEncodedFormat param to specify exactly which characters to encode. This seems like an important thing. Many web services, such as the Amazon SimpleDB service I'm working with, have strict requirements when it comes to encoding.

I am not very good with regular expressions, but that seems like the way to go here. Anybody know how to build a RE to encode the section 2.2 characters, or have you seen any special tags or examples? I just want to pass a string that may have any of those characters, and have it return encoded. Thanks.
TOPICS
Advanced techniques

Views

226

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Feb 27, 2008 Feb 27, 2008
Not sure why I thought REReplace was the way to go, but once again ColdFusion has proven what a delight it is to work with by solving my probem with a single line of code. My co-worker helped me out by suggesting this:

#ReplaceList(string,";,/,?,:,@,=,&,+", "%3B,%2F,%3F,%3A,%40,%3D,%26,%2B")#

Works like a charm.

Votes

Translate

Translate
Contributor ,
Feb 27, 2008 Feb 27, 2008

Copy link to clipboard

Copied

LATEST
Not sure why I thought REReplace was the way to go, but once again ColdFusion has proven what a delight it is to work with by solving my probem with a single line of code. My co-worker helped me out by suggesting this:

#ReplaceList(string,";,/,?,:,@,=,&,+", "%3B,%2F,%3F,%3A,%40,%3D,%26,%2B")#

Works like a charm.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation