code: private static String parseName(String s, StringBuilder sb) {
          sb.setLength(0);
          for (int i = 0; i < s.length(); i++) {
              char c = s.charAt(i); 
              switch (c) {
                  case '+':
                      sb.append(' ');
                      break;
                  case '%':
                      try {
                          sb.append((char) Integer.parseInt(s.substring(i+1, i+3), 
                                  16));
                          i += 2;
                      } catch (NumberFormatException e) {
                          // XXX
                          // need to be more specific about illegal arg
                          throw new IllegalArgumentException();
                      } catch (StringIndexOutOfBoundsException e) {
                          String rest  = s.substring(i);
                          sb.append(rest);
                          if (rest.length()==2)
                              i++;
                          }
  
                          break;
                  default:
                      sb.append(c);
                      break;
              }
          }
  
          return sb.toString();
      }
docs: /*
  Parse a name in the query string.