Beispiel #1
0
 /**
  * ** Decodes the specified hex-encoded argument (not yet fully tested) ** @param sb The
  * StringBuffer where the decoded String argument will be placed ** @param s The String to decode
  * ** @return The StringBuffer where the decoded String will be placed
  */
 public static StringBuffer decodeArg(StringBuffer sb, String s) {
   if (sb == null) {
     sb = new StringBuffer();
   }
   if (s != null) {
     char ch[] = new char[s.length()];
     s.getChars(0, s.length(), ch, 0);
     for (int i = 0; i < ch.length; i++) {
       if (ch[i] == '%') {
         if ((i + 2) < ch.length) {
           int ch1 = StringTools.hexIndex(ch[i + 1]);
           int ch2 = StringTools.hexIndex(ch[i + 2]);
           sb.append((char) (((ch1 << 4) | ch2) & 0xFF));
           i += 2;
         } else {
           i = ch.length - 1;
         }
       } else {
         sb.append(ch[i]);
       }
     }
   }
   return sb;
 }