Solved

CGI ENCODER

Posted on 1999-01-13
5
344 Views
Last Modified: 2013-12-25
Greetings,

I am writing a Unix program which submits some data using the HTTP protocol to a remote CGI script...
I am in need of a C function which will encode a given string (so a CGI program can read it), but I am not sure exactly what should be encoded (i.e. I know all spaces become "+" and fields separated by "&", but don't which characters become hex encoded etc.)
Can anyone provide a C function to Encode a given string?

Thanks.
0
Comment
Question by:idek1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
jconde earned 80 total points
ID: 1830579
The encoding in hexadecimal base.

You must do a for from 0 to strlen(your_string) and if your_string[i] is not numeric, or alphanumeric, you must get the number value of the character, convert it to hex base, and add a % before it.

Example:

this+is+\a\+test

the value for \ is 92, so you need to convert 92 to hex base (5C) and add a % before...

encoded string:

this+is+%5Ca%5C+test

..make any sense??

If you need the code please let me know so I can search my C files!

Regards,

Jorge

0
 

Author Comment

by:idek1
ID: 1830580
Well yes, however, I suspect that the "." (dot) is not encoded and my question is really about what IS and what is NOT encoded using HTTP. Using your algorithm, the "." would be encoded as hex string, because it is neither a character nor a digit, where it really should not be encoded.

idek1
0
 
LVL 7

Expert Comment

by:jconde
ID: 1830581
That depends!!

I have seen browsers that encode everything, and some that don't.

Let me check the algorithms I have (some written by me, some downloaded) and I'll send them to you ok?

--jorge
0
 

Author Comment

by:idek1
ID: 1830582

ok... my email is:
irvingd@bigfoot.com

Thanks for your help,
Idek1
0
 
LVL 8

Expert Comment

by:jhurst
ID: 1830583
As has been said you can encode more than you need.  The ones that need to be encloded are defined in the http protocol specification.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question