code: public static char eatPercentage(String a, int[] n) {
      // Length 0
      if (!a.startsWith("%") || a.length() < 3) {
        n[0] = 0;
        return ((char) 0);
      }
      char c;
      // Try to parse first char
      try {
        c = (char) Integer.parseInt(a.substring(1, 3), 16);
      } catch (Exception e) {
        n[0] = -1;
        return ((char) 0);
      }
      // For non-UTF8, return the char    
      int len = Utf8Length(c);
      n[0] = 3;
      if (len <= 1) return (c);
      // Else collect the UTF8
      String dec = "" + c;
      for (int i = 1; i < len; i++) {
        try {
          dec += (char) Integer.parseInt(a.substring(1 + i * 3, 3 + i * 3), 16);
        } catch (Exception e) {
          return (c);
        }
      }
      // Try to decode the UTF8
      int[] eatLength = new int[1];
      char utf8 = eatUtf8(dec, eatLength);
      if (eatLength[0] != len) return (c);
      n[0] = len * 3;
      return (utf8);
    }
docs: Eats a String of the form "%xx" from a string, where
  xx is a hexadecimal code. If xx is a UTF8 code start,
  tries to complete the UTF8-code and decodes it.