List of utility methods to do Byte Array to Unicode Convert
int | byteArrayBigEndian2Int(byte[] bs) byte Array Big Endian Int return byteArray2Int(bs);
|
int | byteArrayLittleEndian2Int(byte[] bs) byte Array Little Endian Int if (bs.length != 4) throw new IllegalArgumentException(); int res = 0; res |= (bs[3] & BYTE_MASK) << 24; res |= (bs[2] & BYTE_MASK) << 16; res |= (bs[1] & BYTE_MASK) << 8; res |= (bs[0] & BYTE_MASK); return res; ... |
String | bytesToAsciiMaybe(byte[] data) bytes To Ascii Maybe return bytesToAsciiMaybe(data, 0, data.length);
|
String | bytesToAsciiMaybe(byte[] data, int offset, int length) bytes To Ascii Maybe StringBuilder ascii = new StringBuilder(); boolean zeros = false; for (int i = offset; i < offset + length; i++) { int c = data[i] & 0xFF; if (isPrintableAscii(c)) { if (zeros) { return null; ascii.append((char) c); } else if (c == 0) { zeros = true; } else { return null; return ascii.toString(); |
void | lowerToUpper(byte[] b) lower To Upper int len = b.length; if ((len & 1) == 1) { b[len - 1] = '\0'; len--; for (int i = 0; i < len; i += 2) { int high = b[i] & 0xff; int low = b[i + 1] & 0xff; ... |
void | lowerToUpperLatin(byte[] b) lower To Upper Latin int len = b.length; for (int i = 0; i < len; i++) { int ch = b[i] & 0xff; if (ch == '\0') { break; } else if ((ch >= 0x61 && ch <= 0x7a) || (ch >= 0xe0 && ch <= 0xf6) || (ch >= 0xf8 && ch <= 0xfe)) { ... |
String | jisx0208ToString(byte[] b) jisx To String return jisx0208ToString(b, 0, b.length);
|
String | jisx0208ToString(byte[] b, int offset, int len) jisx To String byte[] buf = new byte[len]; for (int i = 0; i < len; i++) { if (b[offset + i] != '\0') { buf[i] = (byte) (b[offset + i] | 0x80); } else { buf[i] = '\0'; String str = null; try { str = new String(buf, "EUC-JP"); } catch (UnsupportedEncodingException e) { str = new String(buf); return str.trim(); |
String | toBase58(byte[] b) to Base if (b.length == 0) { return ""; int lz = 0; while (lz < b.length && b[lz] == 0) { ++lz; StringBuffer s = new StringBuffer(); ... |
byte[] | ushort2bytesBE(int val, byte[] b, int off) ushortbytes BE b[off] = (byte) (val >>> 8); b[off + 1] = (byte) val; return b; |