code: private static String decode(String s) {
      int n = INITIAL_N;
      int i = 0;
      int bias = INITIAL_BIAS;
      StringBuffer output = new StringBuffer();
      int d = s.lastIndexOf(DELIMITER);
      if (d > 0) {
        for (int j = 0; j < d; j++) {
          char c = s.charAt(j);
          if (!basicCodePoint(c)) {
            throw new IllegalArgumentException("bad input: " + c);
          }
          output.append(c);
        }
        d++;
      } else {
        d = 0;
      }
      while (d < s.length()) {
        int oldi = i;
        int w = 1;
        for (int k = BASE;; k += BASE) {
          if (d == s.length()) {
            throw new IllegalArgumentException("bad input: " + d);
          }
          int c = s.charAt(d++);
          int digit = decodeDigit(c);
          if (digit > (Integer.MAX_VALUE - i) / w) {
            throw new IllegalArgumentException("encoding overflow");
          }
          i = i + digit * w;
          int t;
          if (k <= bias) {
            t = TMIN;
          } else if (k >= bias + TMAX) {
            t = TMAX;
          } else {
            t = k - bias;
          }
          if (digit < t) {
            break;
          }
          w = w * (BASE - t);
        }
        bias = adapt(i - oldi, output.length() + 1, oldi == 0);
        if (i / (output.length() + 1) > Integer.MAX_VALUE - n) {
          throw new IllegalArgumentException("encoding overflow");
        }
        n = n + i / (output.length() + 1);
        i = i % (output.length() + 1);
        output.insert(i, (char) n);
        i++;
      }
  
      return output.toString();
    }
docs: Convert a Punycode/ASCII string to Unicode.