CURLcode Curl_idnconvert_hostname(struct Curl_easy *data,
                                  struct hostname *host)
{
#ifndef USE_LIBIDN2
  (void)data;
  (void)data;
#elif defined(CURL_DISABLE_VERBOSE_STRINGS)
  (void)data;
#endif

  /* set the name we use to display the host name */
  host->dispname = host->name;

  /* Check name for non-ASCII and convert hostname to ACE form if we can */
  if(!Curl_is_ASCII_name(host->name)) {
#ifdef USE_LIBIDN2
    if(idn2_check_version(IDN2_VERSION)) {
      char *ace_hostname = NULL;
#if IDN2_VERSION_NUMBER >= 0x00140000
      /* IDN2_NFC_INPUT: Normalize input string using normalization form C.
         IDN2_NONTRANSITIONAL: Perform Unicode TR46 non-transitional
         processing. */
      int flags = IDN2_NFC_INPUT | IDN2_NONTRANSITIONAL;
#else
      int flags = IDN2_NFC_INPUT;
#endif
      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(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 */
        host->name = host->encalloc;
      }
      else {
        failf(data, "Failed to convert %s to ACE; %s", host->name,
              idn2_strerror(rc));
        return CURLE_URL_MALFORMAT;
      }
    }
#elif defined(USE_WIN32_IDN)
    char *ace_hostname = NULL;

    if(curl_win32_idn_to_ascii(host->name, &ace_hostname)) {
      host->encalloc = ace_hostname;
      /* change the name pointer to point to the encoded hostname */
      host->name = host->encalloc;
    }
    else {
      char buffer[STRERROR_LEN];
      failf(data, "Failed to convert %s to ACE; %s", host->name,
            Curl_winapi_strerror(GetLastError(), buffer, sizeof(buffer)));
      return CURLE_URL_MALFORMAT;
    }
#else
    infof(data, "IDN support not present, can't parse Unicode domains");
#endif
  }
  return CURLE_OK;
}
CURLcode Curl_idnconvert_hostname(struct Curl_easy *data,
                                  struct hostname *host)
{
#ifndef USE_LIBIDN2
  (void)data;
  (void)data;
#elif defined(CURL_DISABLE_VERBOSE_STRINGS)
  (void)data;
#endif

   
  host->dispname = host->name;

   
  if(!Curl_is_ASCII_name(host->name)) {
#ifdef USE_LIBIDN2
    if(idn2_check_version(IDN2_VERSION)) {
      char *ace_hostname = NULL;
#if IDN2_VERSION_NUMBER >= 0x00140000
       
      int flags = IDN2_NFC_INPUT | IDN2_NONTRANSITIONAL;
#else
      int flags = IDN2_NFC_INPUT;
#endif
      int rc = IDN2_LOOKUP(host->name, &ace_hostname, flags);
      if(rc != IDN2_OK)
         
        rc = IDN2_LOOKUP(host->name, &ace_hostname,
                         IDN2_TRANSITIONAL);
      if(rc == IDN2_OK) {
        host->encalloc = (char *)ace_hostname;
         
        host->name = host->encalloc;
      }
      else {
        failf(data, "Failed to convert %s to ACE; %s", host->name,
              idn2_strerror(rc));
        return CURLE_URL_MALFORMAT;
      }
    }
#elif defined(USE_WIN32_IDN)
    char *ace_hostname = NULL;

    if(curl_win32_idn_to_ascii(host->name, &ace_hostname)) {
      host->encalloc = ace_hostname;
       
      host->name = host->encalloc;
    }
    else {
      char buffer[STRERROR_LEN];
      failf(data, "Failed to convert %s to ACE; %s", host->name,
            Curl_winapi_strerror(GetLastError(), buffer, sizeof(buffer)));
      return CURLE_URL_MALFORMAT;
    }
#else
    infof(data, "IDN support not present, can't parse Unicode domains");
#endif
  }
  return CURLE_OK;
}