Advertisement
Guest User

Untitled

a guest
May 9th, 2012
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. How do I identify if the string contains a special character which cannot be stored using a utf8-mb4 character set
  2. public static synchronized String toHex(byte [] buf){
  3. StringBuffer strbuf = new StringBuffer(buf.length * 2);
  4. int i;
  5. for (i = 0; i < buf.length; i++) {
  6. if (((int) buf[i] & 0xff) < 0x10){
  7. strbuf.append("0");
  8. }
  9. strbuf.append(Long.toString((int) buf[i] & 0xff, 16));
  10. }
  11. return strbuf.toString();
  12. }
  13.  
  14. public synchronized static byte[] hexToBytes(String hexString) {
  15. HexBinaryAdapter adapter = new HexBinaryAdapter();
  16. byte[] bytes = adapter.unmarshal(hexString);
  17. return bytes;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement