cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_easy_escape question

From: Silex <silex0r_at_gmail.com>
Date: Wed, 19 Apr 2006 00:28:37 +0200

> my code:
> --------
> std::string text;
> std::string textencoded;
> text = "Hallöchen 123 curl test";
> textencoded = curl_escape(text.c_str(), text.length());

I just wanted to put your attention on the fact you must curl_free
what curl_escape returns... you could use a function like :

std::string url_encode(const std::string& str)
{
        char* tmp = curl_escape(str.c_str(), str.size());
        if(!tmp)
                throw std::bad_alloc();
        std::string encoded(tmp);
        curl_free(tmp);
        return encoded;
}
Received on 2006-04-19