'What is the first parameter of curl_easy_escape for?
The curl_easy_escape function of curl takes a CURL* as its first parameter, as curl’s documentation indicates:
char *curl_easy_escape(CURL *curl, const char *string, int length);
↑
I don’t understand what this parameter is used for, since escaping a URL shouldn’t need a curl handle. In fact, curl’s source code ignores this parameter.
Is it safe to simply use NULL for this parameter if I need to escape an URL without having a curl handle beforehand, as the implementation of curl_escape does?
Solution 1:[1]
It is for backward ABI compatibility. CURL *curl was used 6 years ago: curl_easy_escape, Curl_convert_to_network.
It was always and is now safe to pass NULL: curl_escape, curl_easy_escape.
The history is interesting. char *curl_unescape(const char *string, int length) was the first function. Later char *curl_easy_escape(CURL *handle, const char *string, int inlength) was introduced for supporting all extended ASCII charsets with help of iconv. And finally curl_easy_escape code was almost rollbacked to curl_unescape and stopped using CURL *handle.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
