/** * Decodes a byte array where each byte represents an ASCII '0' or '1'. * * @param ascii * each byte represents an ASCII '0' or '1' * @return the raw encoded binary where each bit corresponds to a byte in the byte array argument */ public static byte[] fromAscii(final byte[] ascii) { if (isEmpty(ascii)) { return EMPTY_BYTE_ARRAY; } // get length/8 times bytes with 3 bit shifts to the right of the length final byte[] l_raw = new byte[ascii.length >> 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = ascii.length - 1; ii < l_raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if (ascii[jj - bits] == '1') { l_raw[ii] |= BITS[bits]; } } } return l_raw; }
/** * Converts an array of raw binary data into an array of ASCII 0 and 1 character bytes - each byte is a truncated * char. * * @param raw * the raw binary data to convert * @return an array of 0 and 1 character bytes for each bit of the argument * @see org.apache.commons.codec.BinaryEncoder#encode(byte[]) */ public static byte[] toAsciiBytes(final byte[] raw) { if (isEmpty(raw)) { return EMPTY_BYTE_ARRAY; } // get 8 times the bytes with 3 bit shifts to the left of the length final byte[] l_ascii = new byte[raw.length << 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = l_ascii.length - 1; ii < raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if ((raw[ii] & BITS[bits]) == 0) { l_ascii[jj - bits] = '0'; } else { l_ascii[jj - bits] = '1'; } } } return l_ascii; }
/** * Converts an array of raw binary data into an array of ASCII 0 and 1 characters. * * @param raw * the raw binary data to convert * @return an array of 0 and 1 characters for each bit of the argument * @see org.apache.commons.codec.BinaryEncoder#encode(byte[]) */ public static char[] toAsciiChars(final byte[] raw) { if (isEmpty(raw)) { return EMPTY_CHAR_ARRAY; } // get 8 times the bytes with 3 bit shifts to the left of the length final char[] l_ascii = new char[raw.length << 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = l_ascii.length - 1; ii < raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if ((raw[ii] & BITS[bits]) == 0) { l_ascii[jj - bits] = '0'; } else { l_ascii[jj - bits] = '1'; } } } return l_ascii; }
/** * Decodes a byte array where each byte represents an ASCII '0' or '1'. * * @param ascii * each byte represents an ASCII '0' or '1' * @return the raw encoded binary where each bit corresponds to a byte in the byte array argument */ public static byte[] fromAscii(final byte[] ascii) { if (isEmpty(ascii)) { return EMPTY_BYTE_ARRAY; } // get length/8 times bytes with 3 bit shifts to the right of the length final byte[] l_raw = new byte[ascii.length >> 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = ascii.length - 1; ii < l_raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if (ascii[jj - bits] == '1') { l_raw[ii] |= BITS[bits]; } } } return l_raw; }
/** * Decodes a byte array where each byte represents an ASCII '0' or '1'. * * @param ascii * each byte represents an ASCII '0' or '1' * @return the raw encoded binary where each bit corresponds to a byte in the byte array argument */ public static byte[] fromAscii(final byte[] ascii) { if (isEmpty(ascii)) { return EMPTY_BYTE_ARRAY; } // get length/8 times bytes with 3 bit shifts to the right of the length final byte[] l_raw = new byte[ascii.length >> 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = ascii.length - 1; ii < l_raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if (ascii[jj - bits] == '1') { l_raw[ii] |= BITS[bits]; } } } return l_raw; }
/** * Decodes a byte array where each byte represents an ASCII '0' or '1'. * * @param ascii * each byte represents an ASCII '0' or '1' * @return the raw encoded binary where each bit corresponds to a byte in the byte array argument */ public static byte[] fromAscii(final byte[] ascii) { if (isEmpty(ascii)) { return EMPTY_BYTE_ARRAY; } // get length/8 times bytes with 3 bit shifts to the right of the length final byte[] l_raw = new byte[ascii.length >> 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = ascii.length - 1; ii < l_raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if (ascii[jj - bits] == '1') { l_raw[ii] |= BITS[bits]; } } } return l_raw; }
/** * Converts an array of raw binary data into an array of ASCII 0 and 1 characters. * * @param raw * the raw binary data to convert * @return an array of 0 and 1 characters for each bit of the argument * @see org.apache.commons.codec.BinaryEncoder#encode(byte[]) */ public static char[] toAsciiChars(final byte[] raw) { if (isEmpty(raw)) { return EMPTY_CHAR_ARRAY; } // get 8 times the bytes with 3 bit shifts to the left of the length final char[] l_ascii = new char[raw.length << 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = l_ascii.length - 1; ii < raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if ((raw[ii] & BITS[bits]) == 0) { l_ascii[jj - bits] = '0'; } else { l_ascii[jj - bits] = '1'; } } } return l_ascii; }
/** * Decodes a byte array where each byte represents an ASCII '0' or '1'. * * @param ascii * each byte represents an ASCII '0' or '1' * @return the raw encoded binary where each bit corresponds to a byte in the byte array argument */ public static byte[] fromAscii(final byte[] ascii) { if (isEmpty(ascii)) { return EMPTY_BYTE_ARRAY; } // get length/8 times bytes with 3 bit shifts to the right of the length final byte[] l_raw = new byte[ascii.length >> 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = ascii.length - 1; ii < l_raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if (ascii[jj - bits] == '1') { l_raw[ii] |= BITS[bits]; } } } return l_raw; }
/** * Converts an array of raw binary data into an array of ASCII 0 and 1 character bytes - each byte is a truncated * char. * * @param raw * the raw binary data to convert * @return an array of 0 and 1 character bytes for each bit of the argument * @see org.apache.commons.codec.BinaryEncoder#encode(byte[]) */ public static byte[] toAsciiBytes(final byte[] raw) { if (isEmpty(raw)) { return EMPTY_BYTE_ARRAY; } // get 8 times the bytes with 3 bit shifts to the left of the length final byte[] l_ascii = new byte[raw.length << 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = l_ascii.length - 1; ii < raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if ((raw[ii] & BITS[bits]) == 0) { l_ascii[jj - bits] = '0'; } else { l_ascii[jj - bits] = '1'; } } } return l_ascii; }
/** * Converts an array of raw binary data into an array of ASCII 0 and 1 character bytes - each byte is a truncated * char. * * @param raw * the raw binary data to convert * @return an array of 0 and 1 character bytes for each bit of the argument * @see org.apache.commons.codec.BinaryEncoder#encode(byte[]) */ public static byte[] toAsciiBytes(final byte[] raw) { if (isEmpty(raw)) { return EMPTY_BYTE_ARRAY; } // get 8 times the bytes with 3 bit shifts to the left of the length final byte[] l_ascii = new byte[raw.length << 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = l_ascii.length - 1; ii < raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if ((raw[ii] & BITS[bits]) == 0) { l_ascii[jj - bits] = '0'; } else { l_ascii[jj - bits] = '1'; } } } return l_ascii; }
/** * Converts an array of raw binary data into an array of ASCII 0 and 1 characters. * * @param raw * the raw binary data to convert * @return an array of 0 and 1 characters for each bit of the argument * @see org.apache.commons.codec.BinaryEncoder#encode(byte[]) */ public static char[] toAsciiChars(final byte[] raw) { if (isEmpty(raw)) { return EMPTY_CHAR_ARRAY; } // get 8 times the bytes with 3 bit shifts to the left of the length final char[] l_ascii = new char[raw.length << 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = l_ascii.length - 1; ii < raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if ((raw[ii] & BITS[bits]) == 0) { l_ascii[jj - bits] = '0'; } else { l_ascii[jj - bits] = '1'; } } } return l_ascii; }
/** * Converts an array of raw binary data into an array of ASCII 0 and 1 characters. * * @param raw * the raw binary data to convert * @return an array of 0 and 1 characters for each bit of the argument * @see org.apache.commons.codec.BinaryEncoder#encode(byte[]) */ public static char[] toAsciiChars(final byte[] raw) { if (isEmpty(raw)) { return EMPTY_CHAR_ARRAY; } // get 8 times the bytes with 3 bit shifts to the left of the length final char[] l_ascii = new char[raw.length << 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = l_ascii.length - 1; ii < raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if ((raw[ii] & BITS[bits]) == 0) { l_ascii[jj - bits] = '0'; } else { l_ascii[jj - bits] = '1'; } } } return l_ascii; }
/** * Converts an array of raw binary data into an array of ASCII 0 and 1 character bytes - each byte is a truncated * char. * * @param raw * the raw binary data to convert * @return an array of 0 and 1 character bytes for each bit of the argument * @see org.apache.commons.codec.BinaryEncoder#encode(byte[]) */ public static byte[] toAsciiBytes(final byte[] raw) { if (isEmpty(raw)) { return EMPTY_BYTE_ARRAY; } // get 8 times the bytes with 3 bit shifts to the left of the length final byte[] l_ascii = new byte[raw.length << 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = l_ascii.length - 1; ii < raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if ((raw[ii] & BITS[bits]) == 0) { l_ascii[jj - bits] = '0'; } else { l_ascii[jj - bits] = '1'; } } } return l_ascii; }
/** * Decodes a byte array where each byte represents an ASCII '0' or '1'. * * @param ascii * each byte represents an ASCII '0' or '1' * @return the raw encoded binary where each bit corresponds to a byte in the byte array argument */ public static byte[] fromAscii(final byte[] ascii) { if (isEmpty(ascii)) { return EMPTY_BYTE_ARRAY; } // get length/8 times bytes with 3 bit shifts to the right of the length final byte[] l_raw = new byte[ascii.length >> 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = ascii.length - 1; ii < l_raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if (ascii[jj - bits] == '1') { l_raw[ii] |= BITS[bits]; } } } return l_raw; }
/** * Converts an array of raw binary data into an array of ASCII 0 and 1 characters. * * @param raw * the raw binary data to convert * @return an array of 0 and 1 characters for each bit of the argument * @see org.apache.commons.codec.BinaryEncoder#encode(byte[]) */ public static char[] toAsciiChars(final byte[] raw) { if (isEmpty(raw)) { return EMPTY_CHAR_ARRAY; } // get 8 times the bytes with 3 bit shifts to the left of the length final char[] l_ascii = new char[raw.length << 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = l_ascii.length - 1; ii < raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if ((raw[ii] & BITS[bits]) == 0) { l_ascii[jj - bits] = '0'; } else { l_ascii[jj - bits] = '1'; } } } return l_ascii; }
/** * Converts an array of raw binary data into an array of ASCII 0 and 1 characters. * * @param raw * the raw binary data to convert * @return an array of 0 and 1 characters for each bit of the argument * @see org.apache.commons.codec.BinaryEncoder#encode(byte[]) */ public static char[] toAsciiChars(final byte[] raw) { if (isEmpty(raw)) { return EMPTY_CHAR_ARRAY; } // get 8 times the bytes with 3 bit shifts to the left of the length final char[] l_ascii = new char[raw.length << 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = l_ascii.length - 1; ii < raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if ((raw[ii] & BITS[bits]) == 0) { l_ascii[jj - bits] = '0'; } else { l_ascii[jj - bits] = '1'; } } } return l_ascii; }
/** * Converts an array of raw binary data into an array of ASCII 0 and 1 character bytes - each byte is a truncated * char. * * @param raw * the raw binary data to convert * @return an array of 0 and 1 character bytes for each bit of the argument * @see org.apache.commons.codec.BinaryEncoder#encode(byte[]) */ public static byte[] toAsciiBytes(final byte[] raw) { if (isEmpty(raw)) { return EMPTY_BYTE_ARRAY; } // get 8 times the bytes with 3 bit shifts to the left of the length final byte[] l_ascii = new byte[raw.length << 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = l_ascii.length - 1; ii < raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if ((raw[ii] & BITS[bits]) == 0) { l_ascii[jj - bits] = '0'; } else { l_ascii[jj - bits] = '1'; } } } return l_ascii; }
/** * Converts an array of raw binary data into an array of ASCII 0 and 1 character bytes - each byte is a truncated * char. * * @param raw * the raw binary data to convert * @return an array of 0 and 1 character bytes for each bit of the argument * @see org.apache.commons.codec.BinaryEncoder#encode(byte[]) */ public static byte[] toAsciiBytes(final byte[] raw) { if (isEmpty(raw)) { return EMPTY_BYTE_ARRAY; } // get 8 times the bytes with 3 bit shifts to the left of the length final byte[] l_ascii = new byte[raw.length << 3]; /* * We decr index jj by 8 as we go along to not recompute indices using multiplication every time inside the * loop. */ for (int ii = 0, jj = l_ascii.length - 1; ii < raw.length; ii++, jj -= 8) { for (int bits = 0; bits < BITS.length; ++bits) { if ((raw[ii] & BITS[bits]) == 0) { l_ascii[jj - bits] = '0'; } else { l_ascii[jj - bits] = '1'; } } } return l_ascii; }