The list of methods to do String Encode are organized into topic(s).
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) ||
...
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;