code: public static String toASCII(String s, int flags) {
      String[] parts = SEPARATORS_REGEX.split(s);
      for (int i = 0; i < parts.length; i++) {
        if (nonASCII(parts[i])) {
          parts[i] = PUNYCODE_PREFIX + encode(parts[i]);
        }
      }
      return String.join(".", parts);
    }
docs: Convert a Unicode string to IDN.