List of utility methods to do String Encode
byte[] | encodeString(String s) encode String try { return s.getBytes("MACROMAN"); } catch (UnsupportedEncodingException uee) { ByteArrayOutputStream bs = new ByteArrayOutputStream(s.length()); for (char ch : s.toCharArray()) { if (ch < 0x80) bs.write(ch); else { ... |
byte[] | encodeString(String s, boolean useUnicode) Encodes the string to a byte array using UTF-16LE or the ASCII charset in function of the useUnicode argument.
if (useUnicode) { return getUTFStringAsByteArray(s); return getOEMStringAsByteArray(s); |
byte[] | encodeString(String s, Integer size) encode String byte[] result = null; try { result = s.getBytes("ASCII"); } catch (java.io.UnsupportedEncodingException e) { result = s.getBytes(); return (size == null) ? result : alignToSize(result, size); |
String | encodeString(String s, String charset) Encodes a string into Base64 format. return new String(encode(s.getBytes(charset))); |
String | encodeString(String sourceString, String sysCharset, String charset) encode String if (sourceString == null || sourceString.length() == 0) return sourceString; return new String(sourceString.getBytes(sysCharset), "GB2312"); |
String | encodeString(String str) Encode a string using Base64 encoding. BASE64Encoder encoder = new BASE64Encoder(); String encodedStr = encoder.encodeBuffer(str.getBytes()); return (encodedStr.trim()); |
String | encodeString(String strData) encode String to Base64 if (strData == null) return ""; try { byte[] bytes = strData.getBytes("UTF8"); return encode(bytes).replace("\n", ""); } catch (IOException ie) { ie.printStackTrace(); return ""; |
String | encodeString(String text, String charsetName) encode String if (text != null) { byte bbb[] = text.getBytes(); try { return new String(bbb, charsetName); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return text; ... |
String | encodeString(String value) Base64 encodes the specified string. ByteArrayInputStream in = new ByteArrayInputStream(value.getBytes(ENCODING)); ByteArrayOutputStream out = new ByteArrayOutputStream(); encode(in, out); return out.toString(); |
String | encodeStringByUTF8(String str) encode String By UTF if (isBlank(str)) return ""; try { return URLEncoder.encode(str, "utf-8"); } catch (UnsupportedEncodingException e) { return ""; |