Convert <code>%</code><i>hh</i> sequences to single characters, and
convert plus to space.
@param s A string that may contain
<code>+</code>&nbsp;<small>(plus)</small> and
<code>%</code><i>hh</i> sequences.
@return The unescaped string.
974875
public static String unescape(String s) {
        int len = s.length();
        StringBuffer b = new StringBuffer();
        for (int i = 0; i < len; ++i) {
            char c = s.charAt(i);
            if (c == '+') {
                c = ' ';
            } else if (c == '%' && i + 2 < len) {
                int d = JSONTokener.dehexchar(s.charAt(i + 1));
                int e = JSONTokener.dehexchar(s.charAt(i + 2));
                if (d >= 0 && e >= 0) {
                    c = (char)(d * 16 + e);
                    i += 2;
                }
            }
            b.append(c);
        }
        return b.toString();
    }
171571
public static String unescape(String string) {
        int length = string.length();
        StringBuilder sb = new StringBuilder(length);
        for (int i = 0; i < length; ++i) {
            char c = string.charAt(i);
            if (c == '+') {
                c = ' ';
            } else if (c == '%' && i + 2 < length) {
                int d = JSONTokener.dehexchar(string.charAt(i + 1));
                int e = JSONTokener.dehexchar(string.charAt(i + 2));
                if (d >= 0 && e >= 0) {
                    c = (char)(d * 16 + e);
                    i += 2;
                }
            }
            sb.append(c);
        }
        return sb.toString();
    }
444900
public static String decode(String s) {
    StringBuilder b = new StringBuilder();
    int[] eatLength = new int[1];
    while (s.length() > 0) {
      char c = eatPercentage(s, eatLength);
      if (eatLength[0] <= 0) {
        c = eatAmpersand(s, eatLength);
        if (eatLength[0] <= 0) {
          c = eatBackslash(s, eatLength);
          if (eatLength[0] <= 0) {
            c = eatUtf8(s, eatLength);
            if (eatLength[0] <= 0) {
              c = s.charAt(0);
              eatLength[0] = 1;
            }
          }
        }
      }
      b.append(c);
      s = s.substring(eatLength[0]);
    }
    return (b.toString());
  }
1329938
public static String removeWhiteSpace(String s)
   {
      String retn = null;

      if (s != null)
      {
         int len = s.length();
         StringBuffer sbuf = new StringBuffer(len);

         for (int i = 0; i < len; i++)
         {
            char c = s.charAt(i);

            if (!Character.isWhitespace(c))
               sbuf.append(c);
         }
         retn = sbuf.toString();
      }
      return retn;
   }
107476
public static String normalize(final String s) {
        if (s == null || s.trim().isEmpty()) {
            return "unspecific";
        }
        return s.replace(':', '/')
                .replace('=', '-')
                .replace(',', '|')
                .replace("\"", "")
                .replace('#', '-');
    }
616146
public static int[] stringToCodePoints(final String s) {
        final int m = s.codePointCount(0, s.length());
        final int[] codePoints = new int[m];
        int j = 0;
        for (int offset = 0; offset < s.length();) {
            final int codepoint = s.codePointAt(offset);
            codePoints[j++] = codepoint;
            offset += Character.charCount(codepoint);
        }
        return codePoints;
    }
484237
public static QueryString decode(final String s) {
    final QueryString params = new QueryString();
    String name = null;
    int pos = 0; // Beginning of the unprocessed region
    int i;       // End of the unprocessed region
    for (i = 0; i < s.length(); i++) {
      final char c = s.charAt(i);
      if (c == '=' && name == null) {
        if (pos != i) {
          name = s.substring(pos, i);
        }
        pos = i + 1;
      } else if (c == '&') {
        if (name == null && pos != i) {
          // We haven't seen an `=' so far but moved forward.
          // Must be a param of the form '&a&' so add it with
          // an empty value.
          params.add(s.substring(pos, i), "");
        } else if (name != null) {
          params.add(name, s.substring(pos, i));
          name = null;
        }
        pos = i + 1;
      }
    }

    if (pos != i) {  // Are there characters we haven't dealt with?
      if (name == null) {     // Yes and we haven't seen any `='.
        params.add(s.substring(pos, i), "");
      } else {                // Yes and this must be the last value.
        params.add(name, s.substring(pos, i));
      }
    } else if (name != null) {  // Have we seen a name without value?
      params.add(name, "");
    }

    return params;
  }
1359311
public static byte[] decode( String s )
    {   
        byte[] bytes = s.getBytes();
        return decode( bytes, 0, bytes.length );
    }
384984
public static String encode( String s )
    {
        byte[] sBytes = s.getBytes();
        sBytes = encode( sBytes );
        s = new String( sBytes );
        return s;
    }
438735
public static ByteBuffer stringToBytes(String s) {
    return Unpooled.wrappedBuffer(s.getBytes(StandardCharsets.UTF_8)).nioBuffer();
  }
372845
public static String decode( String s )
        throws IllegalArgumentException
    {
        s = s.replaceAll( "\n", "" );
        s = s.replaceAll( "\r", "" );
        byte[] sBytes = s.getBytes();
        sBytes = decode( sBytes );
        s = new String( sBytes );
        return s;
    }
1104988
public static String normalize(String s) {
    StringBuilder b = new StringBuilder();
    for (int i = 0; i < s.length(); i++)
      b.append(normalize(s.charAt(i)));
    return (b.toString());
  }
186496
private static String base64EncodeToString(String s) {
    final byte[] bytes = s.getBytes(StandardCharsets.ISO_8859_1);
    return Base64.encodeBase64String(bytes);
  }
224813
public static String camelCaseToHyphenCase(String s) {

        StringBuilder parsedString = new StringBuilder(s.substring(0, 1).toLowerCase());

        for (char c : s.substring(1).toCharArray()) {

            if (Character.isUpperCase(c)) {
                parsedString.append("-").append(Character.toLowerCase(c));
            } else {
                parsedString.append(c);
            }
        }

        return parsedString.toString();
    }
1306557
public static byte[] hexStringToByteArray(String s) {
        int len = s.length();
        byte[] data = new byte[len >> 1];
        for (int i = 0, j = 0; j < len; i++) {
            int x = Character.digit(s.charAt(j), 16) << 4;
            j++;
            x = x | Character.digit(s.charAt(j), 16);
            j++;
            data[i] = (byte) (x & 0xFF);
        }
        return data;
    }
758629
public static String decodeUTF8(String s) {
    StringBuilder result = new StringBuilder();
    int[] eatLength = new int[1];
    while (s.length() != 0) {
      char c = eatUtf8(s, eatLength);
      if (eatLength[0] != -1) {
        result.append(c);
        s = s.substring(eatLength[0]);
      } else {
        result.append(s.charAt(0));
        s = s.substring(1);
      }
    }
    return (result.toString());
  }
91760
public static String decode(String s, Charset cs) {
        boolean needToChange = false;
        int numChars = s.length();
        StringBuilder sb = new StringBuilder(numChars > 500 ? numChars / 2 : numChars); // MTD: Using StringBuilder instead of StringBuffer
        int i = 0;

        char c;
        byte[] bytes = null;
        while (i < numChars) {
            c = s.charAt(i);
            switch (c) {
            case '+':
                sb.append(' ');
                i++;
                needToChange = true;
                break;
            case '%':
                /*
                 * Starting with this instance of %, process all
                 * consecutive substrings of the form %xy. Each
                 * substring %xy will yield a byte. Convert all
                 * consecutive  bytes obtained this way to whatever
                 * character(s) they represent in the provided
                 * encoding.
                 */

                try {

                    // (numChars-i)/3 is an upper bound for the number
                    // of remaining bytes
                    if (bytes == null)
                        bytes = new byte[(numChars-i)/3];
                    int pos = 0;

                    while ( ((i+2) < numChars) &&
                            (c=='%')) {
                        int v = Integer.parseInt(s.substring(i+1,i+3),16);
                        if (v < 0)
                            throw new IllegalArgumentException("ExtendedURLDecoder: Illegal hex characters in escape (%) pattern - negative value");
                        bytes[pos++] = (byte) v;
                        i+= 3;
                        if (i < numChars)
                            c = s.charAt(i);
                    }

                    // A trailing, incomplete byte encoding such as
                    // "%x" will cause an exception to be thrown

                    if ((i < numChars) && (c=='%'))
                        throw new IllegalArgumentException(
                         "ExtendedURLDecoder: Incomplete trailing escape (%) pattern");

                    sb.append(new String(bytes, 0, pos, cs)); // MTD: Using the Charset directly instead of first have to look it up from a string at this point
                } catch (NumberFormatException e) {
                    throw new IllegalArgumentException(
                    "ExtendedURLDecoder: Illegal hex characters in escape (%) pattern - "
                    + e.getMessage());
                }
                needToChange = true;
                break;
            default:
                sb.append(c);
                i++;
                break;
            }
        }

        return (needToChange? sb.toString() : s);
    }