Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How do I identify if the string contains a special character which cannot be stored using a utf8-mb4 character set
- public static synchronized String toHex(byte [] buf){
- StringBuffer strbuf = new StringBuffer(buf.length * 2);
- int i;
- for (i = 0; i < buf.length; i++) {
- if (((int) buf[i] & 0xff) < 0x10){
- strbuf.append("0");
- }
- strbuf.append(Long.toString((int) buf[i] & 0xff, 16));
- }
- return strbuf.toString();
- }
- public synchronized static byte[] hexToBytes(String hexString) {
- HexBinaryAdapter adapter = new HexBinaryAdapter();
- byte[] bytes = adapter.unmarshal(hexString);
- return bytes;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement