Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/libcurl/opts/CURLOPT_URL.3
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ expected to be a sequence of characters using an ASCII compatible encoding.

If libcurl is built with IDN support, the server name part of the URL can use
an "international name" by using the current encoding (according to locale) or
UTF-8 (when winidn is used).
UTF-8 (when winidn is used; or a Windows Unicode build using libidn2).

If libcurl is built without IDN support, the server name is used exactly as
specified when passed to the name resolver functions.
Expand Down
14 changes: 11 additions & 3 deletions lib/url.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@
#ifdef USE_LIBIDN2
#include <idn2.h>

#if defined(WIN32) && defined(UNICODE)
#define IDN2_LOOKUP(name, host, flags) \
idn2_lookup_u8((const uint8_t *)name, (uint8_t **)host, flags)
#else
#define IDN2_LOOKUP(name, host, flags) \
idn2_lookup_ul((const char *)name, (char **)host, flags)
#endif

#elif defined(USE_WIN32_IDN)
/* prototype for curl_win32_idn_to_ascii() */
bool curl_win32_idn_to_ascii(const char *in, char **out);
Expand Down Expand Up @@ -1576,12 +1584,12 @@ CURLcode Curl_idnconvert_hostname(struct Curl_easy *data,
#else
int flags = IDN2_NFC_INPUT;
#endif
int rc = idn2_lookup_ul((const char *)host->name, &ace_hostname, flags);
int rc = IDN2_LOOKUP(host->name, &ace_hostname, flags);
if(rc != IDN2_OK)
/* fallback to TR46 Transitional mode for better IDNA2003
compatibility */
rc = idn2_lookup_ul((const char *)host->name, &ace_hostname,
IDN2_TRANSITIONAL);
rc = IDN2_LOOKUP(host->name, &ace_hostname,
IDN2_TRANSITIONAL);
if(rc == IDN2_OK) {
host->encalloc = (char *)ace_hostname;
/* change the name pointer to point to the encoded hostname */
Expand Down