List of utility methods to do UTF8 Encode
String | toUTF8(String isoString) Convert ISO8859-1 format string (which is the default sent by IE to the UTF-8 format that the database is in. String utf8String = null; if (null != isoString && !isoString.equals("")) { try { byte[] stringBytesISO = isoString.getBytes("ISO-8859-1"); utf8String = new String(stringBytesISO, "UTF-8"); } catch (UnsupportedEncodingException e) { System.out.println("UnsupportedEncodingException is: " + e.getMessage()); utf8String = isoString; ... |
String | toUTF8(String s) Encodes a string to UTF8 if (s != null) { try { return new String(s.getBytes("UTF8")); } catch (UnsupportedEncodingException e) { return null; |
String | toUTF8(String sourceStr) to UTF return changeEncoding(sourceStr, "ISO8859-1", "UTF-8"); |
String | toUTF8(String str) to UTF try { return URLEncoder.encode(str, "UTF-8").replace("%2F", "/").replace("+", " "); } catch (UnsupportedEncodingException ex) { return str; |
byte[] | toUTF8(String str) Converts the string to a UTF-8 byte array, turning the checked exception (which should never happen) into a runtime exception. try { if (str == null) return new byte[0]; return str.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException("UTF-8 not supported", e); |
String | toUtf8(String str) to Utf String val = ""; try { val = new String(str.getBytes("UTF-8"), "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return val; |
String | toUTF8(String str) to UTF if (!isNull(str)) { try { str = new String(str.getBytes("ISO8859-1"), "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return str; ... |
byte[] | toUTF8(String string) Convert from a String to UTF-8 bytes. if (string == null) { return null; try { return string.getBytes(UTF_8_ENCODING); } catch (UnsupportedEncodingException e) { throw new IllegalStateException("UTF-8 not supported?", e); |
String | toUTF8(String value) to UTF if (value == null) { return ""; byte[] b = value.getBytes("ISO-8859-1"); return new String(b, "utf-8"); |
byte[] | toUTF8ByteArray(char[] string) to UTF Byte Array ByteArrayOutputStream bOut = new ByteArrayOutputStream(); try { toUTF8ByteArray(string, bOut); } catch (IOException e) { throw new IllegalStateException("cannot encode string to byte array!"); return bOut.toByteArray(); |