![]() |
I've been trying to figure this one out for a while and my brain is fried. Basically, Im trying to write a function that will remove the "%20" thats represents a space in html and relace it with "\ ". Im trying this using the strstr() function, but I really dont know how to start this, or what I need for a basic algorithm. Any thoughts or ideas would be greatly appreciated, or even just a point in the starting direction.
THANKS! Scrag |
Sounds like a fun function. One question and then I would LOVE to help you. Will you be reading an external file or is the user going to be inputing the text into the command line? I might still be able to help if it is with the external file, that just makes things a tad harder. Only because I have not done much with external files, and so I don't have the most experience.
|
It would be easy with an external file...Just use fgets and read one line at a time :)
|
I am writing a web server, I got the web server part pretty much done, but Im adding the ability for the web server to list a directory for downloading files if needed. This will be a function that will be passed a string variable. For example, it gets passed the http string "Cool%20File.mpg", then I need to replace the http space "%20" with "\ " so the unix file system can read the file/cd to the dir. So after the function gets passed the string "Cool%20File.mpg", it should return the string "Cool\ File.mpg"
Thanks for the help!! :) |
If you're writing a webserver than you need to do more than convert just %20. You have to convert every number that appears after a % to its hexadecimal -> character value. Not just 20 for space..
|
Don't know what platform u're writing the program in but there is a function in msdn that does this for you ::: InternetCanonicalizeUrl
|
Yeah, i knoiw I need to convert all number values, but I figured this would be a good start :) I am using C and compiling with gcc, under linux. Im think in gonna write the function to read each char of the string to a new buffer string, then when strstr(httpGET_PATH, "%20), wite out a `\` and a ' ' char, skip 3 chars, continue etc. Any suggestions on a better way would be cool.
Thanks again, Scrag |
There may or may not be a better way to do the if evals... but heres code for %20 that could be easily adapted....
:
void convertURL(char *blah) { |
Thanks a lot tempest!!! Definetly gets me going in the right direction :)
I've been struggling with this for a while now, and other forums didnt seem to help. Thanks again! :rock: |
On second thought/compile, it works flawlessly,
Thanks again! :mrgreen: |
| All times are GMT -5. The time now is 4:04 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC