code: public static String convertHostToPunycode(String uriString) {
  
          if (uriString.indexOf(":") >= 0) {
              try {
                  URI uri = new URI(uriString);
                  String authority = uri.getAuthority(); // getHost won't work when we have special characters
                  int colonPos = authority.indexOf(':');
                  if (colonPos >= 0) {
                      authority = IDN.toASCII(authority.substring(0, colonPos)) + authority.substring(colonPos);
                  } else {
                      authority = IDN.toASCII(authority);
                  }
                  URI uriWithCorrectedHost = new URI(
                      uri.getScheme(),
                      authority,
                      uri.getPath(),
                      uri.getQuery(),
                      uri.getFragment());
                  uriString = uriWithCorrectedHost.toASCIIString();
              } catch (URISyntaxException e) {
                  LOG.error(e.getLocalizedMessage(), e);
              }
          }
          return uriString;
      }
docs: Converts the host of an URI to Punycode.<p>
  
  This is needed when we want to do redirects to hosts with host names containing international characters like umlauts.<p>
  
  @param uriString the URI
  @return the converted URI