List of utility methods to do String Encode
String | encode(final String s) Encode a string for inclusion in a URI (according to RFC 2396). final byte[] bytes = s.trim().getBytes("UTF-8"); final int count = bytes.length; final String allowed = "=,+;.'-@&/$_()!~*:"; final char[] buf = new char[3 * count]; int j = 0; for (int i = 0; i < count; i++) { if ((bytes[i] >= 0x61 && bytes[i] <= 0x7A) || (bytes[i] >= 0x41 && bytes[i] <= 0x5A) || ... |
String | encode(final String s) encode return encode(s, "UTF-8"); |
String | encode(final String s, final String encoding) Encodes thh given string using the provided encoding. if ("utf-8".equalsIgnoreCase(encoding)) { return encodeUTF8(s); return encodeBytes(s.getBytes(encoding)); |
String | encode(final String source, final String encoding, BitSet notEncoded) encode byte[] bytes = encode(source.getBytes(encoding), notEncoded); return new String(bytes, "US-ASCII"); |
String | encode(String data, String encode) encode return encode(data, encode, null);
|
byte[] | encode(String encoding, String string) encode if (encoding == null) { return string.getBytes(); } else { return string.getBytes(encoding); |
byte[] | encode(String encoding, String text) Encodes a String from unicode to the specified encoding. if (text != null) { if (encoding == null) return text.getBytes(); try { return text.getBytes(encoding); } catch (UnsupportedEncodingException e) { return null; |
String | encode(String name) encode StringBuilder sb = new StringBuilder(); for (int i = 0; i < name.length(); i++) { char c = name.charAt(i); if (c != '_' && Character.isLetterOrDigit(c)) sb.append(c); else { String esc = String.format("_%02x", (int) c); sb.append(esc); ... |
String | encode(String s) encode boolean needToChange = false; boolean wroteUnencodedChar = false; int maxBytesPerChar = 10; StringBuffer out = new StringBuffer(s.length()); ByteArrayOutputStream buf = new ByteArrayOutputStream(maxBytesPerChar); OutputStreamWriter writer; try { writer = new OutputStreamWriter(buf, "UTF-8"); ... |
String | encode(String s) encode try { return new String(encodeToChar(s.getBytes("UTF-8"), false)); } catch (UnsupportedEncodingException e) { System.err.println("Base64 encoding error: " + e.getMessage()); e.printStackTrace(); return null; |