Convert one 6 bit ASCII character to 8 bit ASCII character

@param byteToConvert
@return
168960
@VisibleForTesting
	static byte convert6BitCharToStandardAscii(byte byteToConvert) {

		byte b = 0;
		if (byteToConvert < 32) {
			b = (byte) (byteToConvert + 64);
		} else if (byteToConvert < 63) {
			b = byteToConvert;
		}

		return b;
	}
427411
public static String getUS7ASCIIEquiv(String convertString) {
    if (convertString == null)
      return null;

    StringBuilder convertedString = new StringBuilder();
    String upperConvertString = convertString.toUpperCase();

    Collator collator = Collator.getInstance(Locale.US);
    collator.setStrength(Collator.PRIMARY);

    String chars = "abcdefghijklmnopqrstuvwxyz";
    for (int i = 0; i < convertString.length(); i++) {
      char currentChar = convertString.charAt(i);
      boolean isUppercase = currentChar == upperConvertString.charAt(i);
      char mappedChar = ' ';
      if (currentChar < 128) {
        // Within low-ascii, leave it alone.
        mappedChar = currentChar;
      } else if (currentChar < 256) {
        for (int j = 0; j < chars.length(); j++) {
          if (collator.compare(currentChar + "", chars.charAt(j) + "") == 0) {
            if (isUppercase)
              mappedChar = Character.toUpperCase(chars.charAt(j));
            else
              mappedChar = chars.charAt(j);
            break;
          }
        }
      } else {
        // Out of our mapping range. It just becomes a space
      }
      convertedString.append(mappedChar);
    }
    return convertedString.toString();
  }
647273
public static String toStringUTF8(byte[] bytes)
    {
        if (bytes == null)
        {
            return null;
        }

        return toStringUTF8(bytes, 0, bytes.length);
    }
619797
def bits_to_bytes(bits):
    
    if len(bits) % 8 != 0:
        raise Exception("num bits must be multiple of 8")

    res = ""

    for x in six.moves.range(0, len(bits), 8):
        byte_bits = bits[x:x+8]
        byte_val = int(''.join(map(str, byte_bits)), 2)
        res += chr(byte_val)

    return utils.binary(res)
415280
static private String convertByteArrToString(byte[] byteArr) {
    StringBuilder sb = new StringBuilder();
    for (byte b : byteArr) {
      int i = b;
      i = i & 0xff;
      sb.append(String.format("%02x", i));
    }
    return sb.toString();
  }
508863
public static int bytesToInt(byte[] bytes, int offset) {
        // 
        int result = 0x00000000;

        int length;
        if (bytes.length - offset < 4) // maximum byte size for int data type
                                        // is 4
            length = bytes.length - offset;
        else
            length = 4;

        int end = offset + length;
        for (int i = 0; i < length; i++) {
            result |= (bytes[end - i - 1] & 0xff) << (8 * i); // TODO uudashr: CHECK FOR IMPROVEMENT
        }
        return result;
    }
871381
@Nullable
    public static String convertISO2022CharsetToJavaCharset(@NotNull final byte[] bytes)
    {
        if (bytes.length > 2 && bytes[0] == ESC && bytes[1] == PERCENT_SIGN && bytes[2] == LATIN_CAPITAL_G)
            return UTF_8;

        if (bytes.length > 3 && bytes[0] == ESC && (bytes[3] & 0xFF | ((bytes[2] & 0xFF) << 8) | ((bytes[1] & 0xFF) << 16)) == DOT && bytes[4] == LATIN_CAPITAL_A)
            return ISO_8859_1;

        return null;
    }
1063909
def tob(data, enc='utf8'):
    
    return data.encode(enc) if isinstance(data, six.text_type) else bytes(data)
304810
public static byte[] utf8Encode(CharSequence string) {
		try {
			ByteBuffer bytes = UTF8.newEncoder().encode(CharBuffer.wrap(string));
			byte[] bytesCopy = new byte[bytes.limit()];
			System.arraycopy(bytes.array(), 0, bytesCopy, 0, bytes.limit());
			return bytesCopy;
		}
		catch (CharacterCodingException e) {
			throw new RuntimeException(e);
		}
	}
532902
public static String toHex(byte b) {
    final char[] string = { hexDigits[(b >> 4) & 0x0f], hexDigits[b & 0x0f] };
    return new String(string);
  }
69115
public static String encode(byte[] from) {
        StringBuilder to = new StringBuilder((int) (from.length * 1.34) + 3);
        int num = 0;
        char currentByte = 0;
        for (int i = 0; i < from.length; i++) {
            num = num % 8;
            while (num < 8) {
                switch (num) {
                    case 0:
                        currentByte = (char) (from[i] & lead6byte);
                        currentByte = (char) (currentByte >>> 2);
                        break;
                    case 2:
                        currentByte = (char) (from[i] & last6byte);
                        break;
                    case 4:
                        currentByte = (char) (from[i] & last4byte);
                        currentByte = (char) (currentByte << 2);
                        if ((i + 1) < from.length) {
                            currentByte |= (from[i + 1] & lead2byte) >>> 6;
                        }
                        break;
                    case 6:
                        currentByte = (char) (from[i] & last2byte);
                        currentByte = (char) (currentByte << 4);
                        if ((i + 1) < from.length) {
                            currentByte |= (from[i + 1] & lead4byte) >>> 4;
                        }
                        break;
                    default:
                        break;
                }
                to.append(encodeTable[currentByte]);
                num += 6;
            }
        }
        if (to.length() % 4 != 0) {
            for (int i = 4 - to.length() % 4; i > 0; i--) {
                to.append("=");
            }
        }
        return to.toString();
    }
272601
public static int byteArrayToInt(byte[] b, int offset) {
        int value = 0;
        for (int i = 0; i < 4; i++) {
            int shift = (4 - 1 - i) * 8;
            value += (b[i + offset] & 0x000000FF) << shift;
}
        return value;
    }
728638
public static long fromBytes(byte[] value){
        if (value == null) return 0;
        long out = 0;
        int length = value.length;
        if (length > 8) length = 8;
        for (int i = 0; i < length; i++){
            out = (out << 8) + (value[i] & 0xff);
        }
        return out;
    }
800239
public static byte[] longToByteArrayBE( long data ) {
        return new byte[]{(byte) ((data >> 56) & 0xff), (byte) ((data >> 48) & 0xff), (byte) ((data >> 40) & 0xff),
                (byte) ((data >> 32) & 0xff), (byte) ((data >> 24) & 0xff), (byte) ((data >> 16) & 0xff),
                (byte) ((data >> 8) & 0xff), (byte) ((data >> 0) & 0xff),};
    }
185889
public static char bytesToChar(byte[] bytes, int offset) {
        char result = 0x0;
        for (int i = offset; i < offset + 2; ++i) {
            result = (char) ((result) << 8);
            result |= (bytes[i] & 0x00FF);
        }
        return result;
    }
479463
public com.google.protobuf.ByteString getCharactersToSkipBytes() {
    java.lang.Object ref = "";
    if (charactersCase_ == 1) {
      ref = characters_;
    }
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
      if (charactersCase_ == 1) {
        characters_ = b;
      }
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }
173001
public int readUTF8ByByteLength(char []buffer, int offset, int byteLength)
    throws IOException
  {
    int k = 0;
    for (int i = 0; i < byteLength; i++) {
      if (_readLength <= _readOffset) {
        readBuffer();
      }

      int ch = _readBuffer[_readOffset++] & 0xff;

      if (ch < 0x80) {
        buffer[k++] = (char) ch;
      }
      else if ((ch & 0xe0) == 0xc0) {
        int c2 = read();
        i += 1;
        buffer[k++] = (char) (((ch & 0x1f) << 6) + (c2 & 0x3f));
      }
      else {
        int c2 = read();
        int c3 = read();

        i += 2;
        buffer[k++] = (char) (((ch & 0x1f) << 12)
                              + ((c2 & 0x3f) << 6)
                              + ((c3 & 0x3f)));
      }
    }

    return k;
  }