cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: url string whitespace etc...

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 6 Mar 2002 08:56:20 +0100 (MET)

On Tue, 5 Mar 2002, rick vaillancourt wrote:

> I have a known url string that I have done hardcoded replacement of spaces
> to %20 and quotes to /" etc...
>
> I have been looking, but have not found in the C api for a curl_... call
> that would do this kind of substitution. I also checked the examples, but,
> didn't find anything there either.

It is called curl_escape(). Man page online is found here:
http://curl.haxx.se/libcurl/c/curl_escape.html

It is used like this:

 char *raw_string = " string with spaces ";

 char *url = curl_escape( raw_string, strlen(raw_string) );

 if(url) {

   printf("Converted: %s\n", url);

   free(url); /* not that the string must be freed after having been used */

 }

-- 
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
Received on 2002-03-06