I gave it shot utilizing that method of trying to get the program to change a space into a +, but nothing is working.
I've tried to put this bit of code in several placed throughout the function thinking it would be fine, but no luck.. grrr it doesn't make sense, I've commented where I think it should logically go.
Code:
if(source[i] == ' ') {
destination[destc] = '+';
}
Code:
void URLEncode(char* destination,int length, char* source){
//local variables
int destc=0;
int i;
int a;
int clear=0;
for(i=0;destc+1<length&&source[i];i++){
clear=0;
for(a=0;nonencode[a];a++){
if(nonencode[a]==source[i]){
clear=1;
break;
}
//snippet to change space to + should work fine here but doesn't
}
if(!clear){
if(destc+3>=length){
break;
}
destination[destc]='%';
destination[destc+1]=hexa[source[i]/16];
destination[destc+2]=hexa[source[i]%16];
destc+=3;
}
else{
destination[destc]=source[i];
destc++;
}
}
destination[destc]='\0';
}
Then I tried lasterlight's suggestion to make another function called isEncodable to take some code of out the URLEncode function but I'd rather keep it the way it is without calling another function, then I had to leave for class and haven't had a chance to really get back to it.
Code:
// not real function just an idea
void isEncodeable(char* source) {
//local variables
int destc=0;
int i;
int a;
int clear=0;
for(i=0;destc+1<length&&source[i];i++){
clear=0;
for(a=0;nonencode[a];a++){
if(nonencode[a]==source[i]){
clear=1;
break;
}
}
}
Thanks again for the help with this nagging problem
had another idea of trying this
Code:
if(destination[destc] == '%20') {
destination[destc] = '+';
}
and putting that right after the encoding part of the function but that didn't work either