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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need URLEncode Object, or need to make one with the following rules

Status
Not open for further replies.

Karl Blessing

Programmer
Feb 25, 2000
2,936
US
I need to find out if VC++ has a URL Encode, if not, i'll need to make a function, when a string(or character array) is passed itno it, the following things will change<br>
1) a-z, A-Z, 0-9 remain the same<br>
2) all spaces are changed to +<br>
3) all other charaters are converted to %xy where xy is the two digit hexidecimal intepretation of the ANSI table's lower bit(0-128)<br>
<br>
for example somehting like &quot;hi my name is Karl! whats your name?&quot; would become &quot;hi+my+name+is+Karl%98+whats+your+name%23&quot; (the numbers arnt real i just guessed), reason i need this, is cuz my VC++ program, opens a ASP URL which sends an email for me, by the parameters i pass, it's saftest to encode the messages with this method, so that none of the characters passed will affect the ASP's decoding of the parameter, like an amperstand would really cause a prob.<br>
<br>
I'll be working on this, but I was hoping some might have a quick method of just converting these. <p>Karl<br><a href=mailto:kb244@bellsouth.net>kb244@bellsouth.net</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(hehe, yea it was 4.5 too, least i didnt start with COBOL)
 
figured it out<br>
char buff[128],conv[512], tmpc[25], tmmp[1];<br>
strcpy(conv,&quot;&quot;);<br>
int i=0, tmpi=0;<br>
cout&lt;&lt;&quot;Type in string to convert:&quot;;<br>
cin.getline(buff,128,'\n');<br>
cin.ignore(128,'\n');<br>
while(i&lt;=128 && buff<i>!='\0')<br>
{<br>
if(buff<i>&lt;48 ¦¦ (buff<i>&gt;57 && buff<i>&lt;65) ¦¦ (buff<i>&gt;90 && buff<i>&lt;97) ¦¦ (buff<i>&gt;122 && buff<i>&lt;256))<br>
{<br>
if(buff<i> == 32)<br>
strcat(conv,&quot;+&quot;);<br>
else<br>
{<br>
tmpi = buff<i>;<br>
itoa(tmpi,tmpc,16);<br>
strcat(conv,&quot;%&quot;);<br>
strcat(conv,tmpc);<br>
}<br>
}<br>
else<br>
{<br>
tmmp[0] = buff<i>;<br>
tmmp[1] = '\0';<br>
strcat(conv,tmmp);<br>
}<br>
i++;<br>
}<br>
cout&lt;&lt;conv&lt;&lt;endl; <p>Karl<br><a href=mailto:kb244@bellsouth.net>kb244@bellsouth.net</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(hehe, yea it was 4.5 too, least i didnt start with COBOL)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top