code: public static String resilientUrlDecode(String input) {
          String cookedInput = input;
  
          if (cookedInput.indexOf('%') > -1) {
              // Transform all existing UTF-8 standard into UTF-16 standard.
              cookedInput = VALID_STANDARD.matcher(cookedInput).replaceAll("%00%$1");
  
              // Discard chopped encoded char at the end of the line (there is no way to know what it was)
              cookedInput = CHOPPED_STANDARD.matcher(cookedInput).replaceAll("");
  
              // Handle non standard (rejected by W3C) encoding that is used anyway by some
              // See: https://stackoverflow.com/a/5408655/114196
              if (cookedInput.contains("%u")) {
                  // Transform all existing non standard into UTF-16 standard.
                  cookedInput = VALID_NON_STANDARD.matcher(cookedInput).replaceAll("%$1%$2");
  
                  // Discard chopped encoded char at the end of the line
                  cookedInput = CHOPPED_NON_STANDARD.matcher(cookedInput).replaceAll("");
              }
          }
  
          try {
              return URLDecoder.decode(cookedInput, "UTF-16");
          } catch (UnsupportedEncodingException e) {
              // Will never happen because the encoding is hardcoded
              return null;
          }
      }
docs: The main goal of the resilientUrlDecode is to have a UrlDecode that keeps working
  even if the input is seriously flawed or even uses a rejected standard.
  @param input the UrlEncoded input string
  @return Url decoded result string