Java Utililty Methods ASCII to Binary

List of utility methods to do ASCII to Binary

Description

The list of methods to do ASCII to Binary are organized into topic(s).

Method

booleanascii2bin(byte[] ascii, int offset, int len, byte[] binary)
asciibin
assert len % 2 == 0;
assert binary.length >= len >>> 1;
boolean zeroBytes = true;
for (int i = 0, j = offset; i < len >>> 1; i++) {
    int b = ascii[j++] & 0xCF; 
    int hiNibble = b > 64 ? b - 55 : b;
    b = ascii[j++] & 0xCF;
    int lowNibble = b > 64 ? b - 55 : b;
...
StringAsciiToBinary(String asciiString)
Ascii To Binary
byte[] bytes = asciiString.getBytes();
StringBuilder binary = new StringBuilder();
for (byte b : bytes) {
    int val = b;
    for (int i = 0; i < 8; i++) {
        binary.append((val & 128) == 0 ? 0 : 1);
        val <<= 1;
return binary.toString();
byteasciiToRawQuality(char quality)
ascii To Raw Quality
return (byte) (quality - PHRED_LOWER_LIMIT_CHAR);