Returns {@code binaryString} zero-padded separated by {@code seaparator} in groups of 4.
431951
public static final String prettyPrint(final String binaryString, final char separator) {
    String paddedBinaryString = zeroPadString(binaryString);
    List<String> splitted = Splitter.fixedLength(4).splitToList(paddedBinaryString);
    return Joiner.on(separator).join(splitted);
  }
450979
public static String checkLeadingZeros(String generated, boolean paddingOn) {
        if (paddingOn) {
            return replaceLeadingZero(generated);
        } else {
            return removeLeadingZeros(generated);
        }
        
    }
683198
private byte[] dropPadding(byte[] plainpad) {
    byte plain[] = null;
    int drop = plainpad[plainpad.length - 1]; // last byte gives number of
    // bytes to drop

    // reallocate array smaller, dropping the pad bytes.
    plain = new byte[plainpad.length - drop];
    for (int i = 0; i < plain.length; i++) {
      plain[i] = plainpad[i];
      plainpad[i] = 0; // don't keep a copy of the decrypt
    }
    return plain;
  }
867717
public String readString(final JBBPByteOrder byteOrder) throws IOException {
    final int prefix = this.readByte();
    final int len;
    if (prefix == 0) {
      len = 0;
    } else if (prefix == 0xFF) {
      len = -1;
    } else if (prefix < 0x80) {
      len = prefix;
    } else if ((prefix & 0xF0) == 0x80) {
      switch (prefix & 0x0F) {
        case 1: {
          len = this.readByte();
        }
        break;
        case 2: {
          len = this.readUnsignedShort(byteOrder);
        }
        break;
        case 3: {
          int buffer;
          if (byteOrder == JBBPByteOrder.BIG_ENDIAN) {
            buffer = (this.readByte() << 16) | (this.readByte() << 8) | this.readByte();
          } else {
            buffer = this.readByte() | (this.readByte() << 8) | (this.readByte() << 16);
          }
          len = buffer;
        }
        break;
        case 4: {
          len = this.readInt(byteOrder);
        }
        break;
        default: {
          throw makeIOExceptionForWrongPrefix(prefix);
        }
      }
    } else {
      throw makeIOExceptionForWrongPrefix(prefix);
    }

    final String result;
    if (len < 0) {
      result = null;
    } else if (len == 0) {
      result = "";
    } else {
      result = JBBPUtils.utf8ToStr(this.readByteArray(len));
    }

    return result;
  }
1354507
public byte[] readStringNulByBytes() {
        byte[] result = new byte[byteBuf.bytesBefore((byte) 0)];
        byteBuf.readBytes(result);
        byteBuf.skipBytes(1);
        return result;
    }
317637
function(_binarray){
        var _index = 0,
            _result = [],
            _mode = _binarray.length%3;
        // this is for the padding
        if (_mode==1)
            _binarray.push(0,0);
        if (_mode==2)
            _binarray.push(0);
        // from here conversion
        while(_index<_binarray.length){
            _result.push(__b64char[_binarray[_index]>>2],
                         __b64char[((_binarray[_index]&3)<<4)|(_binarray[_index+1]>>4)],
                         __b64char[((_binarray[_index+1]&15)<<2)|(_binarray[_index+2]>>6)],
                         __b64char[_binarray[_index+2]&63]);
            _index += 3;
        }
        // this is again for the padding
        if (_mode == 1)
            _result[_result.length-1] =
            _result[_result.length-2] = '=';
        if (_mode == 2)
            _result[_result.length-1] = '=';
        // we join the array to return a textstring
        return _result.join('');
    }
1081940
public static BinaryString concatWs(BinaryString separator, Iterable<BinaryString> inputs) {
		if (null == separator || EMPTY_UTF8.equals(separator)) {
			return concat(inputs);
		}
		separator.ensureMaterialized();

		int numInputBytes = 0;  // total number of bytes from the inputs
		int numInputs = 0;      // number of non-null inputs
		for (BinaryString input : inputs) {
			if (input != null) {
				input.ensureMaterialized();
				numInputBytes += input.sizeInBytes;
				numInputs++;
			}
		}

		if (numInputs == 0) {
			// Return an empty string if there is no input, or all the inputs are null.
			return EMPTY_UTF8;
		}

		// Allocate a new byte array, and copy the inputs one by one into it.
		// The size of the new array is the size of all inputs, plus the separators.
		final byte[] result = new byte[numInputBytes + (numInputs - 1) * separator.sizeInBytes];
		int offset = 0;

		int j = 0;
		for (BinaryString input : inputs) {
			if (input != null) {
				int len = input.sizeInBytes;
				SegmentsUtil.copyToBytes(input.segments, input.offset, result, offset, len);
				offset += len;

				j++;
				// Add separator if this is not the last input.
				if (j < numInputs) {
					SegmentsUtil.copyToBytes(separator.segments, separator.offset, result, offset, separator.sizeInBytes);
					offset += separator.sizeInBytes;
				}
			}
		}
		return fromBytes(result);
	}
147423
private int binaryEmptySlotSearch() {

        int low     = 0;
        int high    = count;
        int mid     = 0;
        int compare = 0;

        while (low < high) {
            mid     = (low + high) / 2;
            compare = compare(mid);

            if (compare < 0) {
                high = mid;
            } else if (compare > 0) {
                low = mid + 1;
            } else {
                return -1;
            }
        }

        return low;
    }
585994
public String binaryToString(Object objData) 
    {
        initGlobals();
        if (objData == null)
            return Constants.BLANK;
        synchronized (gIntegerFormat)
        {
            return gIntegerFormat.format(((Integer)objData).intValue());
        }
    }
432164
public String binaryToString(Object objData) 
    {
        initGlobals();
        if (objData == null)
            return Constants.BLANK;
        String string = null;
        synchronized (gNumberFormat)
        {
            if (m_ibScale != 2)
            {
                gNumberFormat.setMinimumFractionDigits(m_ibScale);
                gNumberFormat.setMaximumFractionDigits(m_ibScale);
            }
            string = gNumberFormat.format(((Double)objData).doubleValue());
            if (m_ibScale != 2)
            {
                gNumberFormat.setMinimumFractionDigits(2);
                gNumberFormat.setMaximumFractionDigits(2);
            }
        }
        return string;
    }
661585
public BinaryString toUpperCase() {
		if (javaObject != null) {
			return toUpperCaseSlow();
		}
		if (sizeInBytes == 0) {
			return EMPTY_UTF8;
		}
		int size = segments[0].size();
		SegmentAndOffset segmentAndOffset = startSegmentAndOffset(size);
		byte[] bytes = new byte[sizeInBytes];
		bytes[0] = (byte) Character.toTitleCase(segmentAndOffset.value());
		for (int i = 0; i < sizeInBytes; i++) {
			byte b = segmentAndOffset.value();
			if (numBytesForFirstByte(b) != 1) {
				// fallback
				return toUpperCaseSlow();
			}
			int upper = Character.toUpperCase((int) b);
			if (upper > 127) {
				// fallback
				return toUpperCaseSlow();
			}
			bytes[i] = (byte) upper;
			segmentAndOffset.nextByte(size);
		}
		return fromBytes(bytes);
	}
673262
public String getHexStringLower() {
		int len = getVInt();
		byte[] hex = new byte[len];
		System.arraycopy(buf, bufPosition, hex, 0, hex.length);
		bufPosition += hex.length;
		return toHex(hex, false);
	}
281660
public byte[] toBytes(final int padding) {
    // special case a single entry
    if (padding == 0 && segments.size() == 1) {
      BufferSegment seg = segments.get(0);
      if (seg.offset == 0 && seg.len == seg.buf.length) {
        return seg.buf;
      }
      return Arrays.copyOfRange(seg.buf, seg.offset, seg.offset + seg.len);
    }
    byte[] result = new byte[total_length + padding];
    int ofs = 0;
    for (BufferSegment seg : segments) {
      System.arraycopy(seg.buf, seg.offset, result, ofs, seg.len);
      ofs += seg.len;
    }
    return result;
  }
1331245
@SneakyThrows
    public static String decodeByteArrayToString(final byte[] bytes) {
        @Cleanup
        val bais = new ByteArrayInputStream(bytes);
        @Cleanup
        val baos = new ByteArrayOutputStream();
        val buf = new byte[bytes.length];
        try (val iis = new InflaterInputStream(bais)) {
            var count = iis.read(buf);
            while (count != -1) {
                baos.write(buf, 0, count);
                count = iis.read(buf);
            }
            return new String(baos.toByteArray(), StandardCharsets.UTF_8);
        } catch (final Exception e) {
            LOGGER.error("Base64 decoding failed", e);
            return null;
        }
    }
490058
public static byte[] hexString2Bytes(String hexString) {
        if (StringKit.isBlank(hexString)) return null;
        int len = hexString.length();
        if (len % 2 != 0) {
            hexString = "0" + hexString;
            len = len + 1;
        }
        char[] hexBytes = hexString.toUpperCase().toCharArray();
        byte[] ret      = new byte[len >> 1];
        for (int i = 0; i < len; i += 2) {
            ret[i >> 1] = (byte) (hex2Dec(hexBytes[i]) << 4 | hex2Dec(hexBytes[i + 1]));
        }
        return ret;
    }
1084305
public com.google.protobuf.ByteString getS() {
    if (valueCase_ == 2) {
      return (com.google.protobuf.ByteString) value_;
    }
    return com.google.protobuf.ByteString.EMPTY;
  }
1256587
public static byte[] fromBinaryString(String binaryStr) {
    if (!binaryStr.matches("^[01]*$"))
      throw new IllegalArgumentException("Invalid binary string");
    if (binaryStr.isEmpty()) return new byte[0];

    int complementary = binaryStr.length() % 8;
    if (complementary != 0)
      binaryStr += Ruby.Array.of("0").multiply(8 - complementary).join();
    return rjust(new BigInteger(binaryStr, 2).toByteArray(),
        binaryStr.length() / 8);
  }