0

Anyone know of a tool to completely encode a string to URL encoding? Best known example is something to convert space character to %20. I want to do this for every single character. What's a good tool for this (linux)?

thanks everyone for down voting, if i cared what language i would have specified. couldnt find anything useful in the other post linked below so i wrote this. this is good enough for me, might be good enough for you.

#include <stdio.h>
// Treats all args as one big string. Inserts implicit spaces between args.
int main(int argc, char *argv[])
{
    if(argc == 1)
    {
        printf("Need something to encode.");
        return 1;
    }
    int count = 0;
    while(++count < argc)
    {
        char *input = argv[count];
        while(*input != '\0')
        {
            printf("%%%x", *input);
            input++;
        }
        printf("%%20");
    }
    printf("\n");
    return 0;
}
2
  • 1
    Linux doesn't tell us your development environment. What language are you using? Commented Nov 17, 2010 at 0:26
  • "If I cared what language I would have specified." If you don't care, there is no possible answer to your question. Commented Nov 17, 2010 at 1:09

3 Answers 3

2

Take a look at this SO question:

Sign up to request clarification or add additional context in comments.

Comments

0

Which programming language? You can even do something client-side...

Comments

0

i modified this of the other link

perl -p -e 's/(.)/sprintf("%%%02X", ord($1))/seg'

it works nice enough.. run this.. type in what you want to convert..(or pipe it through) and it'll output everything %encoded

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.