cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: How to use curl_easy_escape on a URL

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 19 May 2009 23:47:43 +0200 (CEST)

On Tue, 19 May 2009, centrio_at_gmail.com wrote:

> I want to use char *curl_easy_escape( CURL * curl , char * url , int length
> ); API to convert
> a URL "http://64.128.66.86/test data.xlx" into something like
> "http://64.128.66.86/test%20data.xlx".

> Libcurl provides this api but I cannot get the exact result I am expecting.

Well, libcurl provides the API for that yes, but not in a single function call
as you have discovered. curl_easy_escape() URL-encodes the entire thing you
give to it, and the letters : and / etc are probably not among the ones you
want to convert but the function will.

You can probably get away by hunting down all slashes after the // pair and
url encoded the pieces individually between the slashes.

-- 
  / daniel.haxx.se
Received on 2009-05-19