Correct way to set url using CURLOPT_URL in libcurl

3 weeks ago 16
ARTICLE AD BOX

I want to use the libcurl library to send HTTP requests. To set the server URL, I use CURLOPT_URL like this:

curl_easy_setopt(curl, CURLOPT_URL, my_url);

I have three questions about this:

What encoding should my_url be in? Should it be UTF-8 or some other encoding?

If the URL contains reserved characters, such as the # character, should I explicitly percent-encode it before calling curl_easy_setopt, or will libcurl handle this automatically?

If the URL contains international characters, should I somehow transform them before setting the URL via CURLOPT_URL?

In my case, the URLs can vary and contain all or some of the three cases mentioned above. How do I correctly send the request in such cases? Proofs with links to documentation are welcome.

P.S: libcurl build with IDN

Read Entire Article