Takes a bytes instance and pads it with null bytes until it's length chars.
344304
def _pad_bytes_new(name, length):
    
    if isinstance(name, str):
        name = bytes(name, 'utf-8')
    return name + b'\x00' * (length - len(name))
946377
function _atob (s) {
   if (s) {
      return new Uint8Array(atob(s).split("").map(function(c) { return c.charCodeAt(0); }));
   } else {
      return null;
   }
}
137199
private <T> T decode(byte[] bytes) {
    return bytes != null ? serializer.decode(bytes) : null;
  }
405955
public static int writeBytes(final BitOutput bitOutput, final int lengthSize, final boolean byteUnsigned,
                                 final int byteSize, final byte[] value)
            throws IOException {
        if (bitOutput == null) {
            throw new NullPointerException("bitOutput is null");
        }
        requireValidSizeInt(true, lengthSize);
        requireValidSizeByte(byteUnsigned, byteSize);
        if (value == null) {
            throw new NullPointerException("value is null");
        }
        final int length = value.length & ((1 << lengthSize) - 1);
        bitOutput.writeInt(true, lengthSize, length);
        for (int i = 0; i < length; i++) {
            bitOutput.writeByte(byteUnsigned, byteSize, value[i]);
        }
        return length;
    }
1084473
public static Charset detect(@NonNull byte[] buffer, int offset, int length) {
      Preconditions.checkArgument(length > 0);
      Preconditions.checkArgument(offset >= 0);

      final com.ibm.icu.text.CharsetDetector detector = new com.ibm.icu.text.CharsetDetector();
      try {
         detector.setText(new ByteArrayInputStream(buffer, offset, length));
         return Charset.forName(detector.detect().getName());
      } catch (Exception e) {
         return null;
      }
   }
1208175
public void readBytes (byte[] bytes, int offset, int count) throws KryoException {
		if (bytes == null) throw new IllegalArgumentException("bytes cannot be null.");
		int copyCount = Math.min(limit - position, count);
		while (true) {
			System.arraycopy(buffer, position, bytes, offset, copyCount);
			position += copyCount;
			count -= copyCount;
			if (count == 0) break;
			offset += copyCount;
			copyCount = Math.min(count, capacity);
			require(copyCount);
		}
	}
1282900
public static String asString(byte[] bytes, Charset charset)
    {
        if (bytes == null)
        {
            return null;
        }

        if (charset == null)
        {
            throw new IllegalArgumentException("Cannot get bytes without a Charset");
        }

        try
        {
            return new String(bytes, charset.name());
        }
        catch (UnsupportedEncodingException e)
        {
            throw new IllegalStateException(charset.name() + " must be present", e);
        }
    }
485671
public static String toHex(byte[] bytes, int offset, int length) {
      return toHex(bytes, offset, length, null);
   }
170506
def set_length(len , fill_char)
      return if len <= 0
      old = char_length
      return if old >= len
      self.char_length = len
      check_length
      fill_from_with( old + 1 , fill_char )
    end
721366
public static String pad( String s, int length )
	{
		// Trim if longer...
		if( s.length() > length )
		{
			return s.substring( 0, length );
		}
		StringBuffer buffer = new StringBuffer(s);
		int spaces = length - s.length();
		while( spaces-- > 0 )
		{
			buffer.append(' ');
		}
		return buffer.toString();
	}
1212664
@Override
    public final Long fromBytes(Class targetClass, byte[] bytes)
    {
        if (bytes == null || bytes.length != 8)
        {
            if (log.isWarnEnabled())
            {
                log.warn("Bytes length not equal to 8");
            }
            return null;
        }
        return (ByteBuffer.wrap(bytes).getLong());
    }
1004146
private static byte[] bytes(char[] chars) {
        byte[] bytes = new byte[chars.length];
        for (int i = 0; i < bytes.length; i++) {
            char c = chars[i];
            bytes[i] = (byte) c;
        }
        return bytes;
    }
806997
private static byte[] toAsciiBytes(String str) {
        for(int i = 0; i < str.length(); i++) {
            if(str.charAt(i) > 127) return null;
        }
        byte[] bytes = new byte[str.length()];
        for(int i = 0; i < str.length(); i++) {
            bytes[i] = (byte)str.charAt(i);
        }
        return bytes;
    }
1358471
def skipNullPadding(self, buff):
        '''
        
        '''
        def readNext(buff, first_run=True):
            datas = unpack('<i', buff.read(4))
            header = datas[0]

            if header == CHUNK_NULL_TYPE and first_run:
                print("Skipping null padding in StringPoolChunk header")
                header = readNext(buff, first_run=False)
            elif header != CHUNK_STRINGPOOL_TYPE:
                print("Invalid StringPoolChunk header")

            return header

        header = readNext(buff)
        return header >> 8, header & 0xFF
997666
private static void padInt(StringBuilder buffer, int value, int length) {
        String strValue = Integer.toString(value);
        for (int i = length - strValue.length(); i > 0; i--) {
            buffer.append('0');
        }
        buffer.append(strValue);
    }
1075706
private static byte[] getBytes(String string, Charset charset) {
        if (string == null) {
            return null;
        }
        return string.getBytes(charset);
    }
701109
function padLeft(val, len, offset, char) {
    /* istanbul ignore if */
    if (!is_1.isValue(val) || !is_1.isString(val))
        return null;
    // If offset is a string
    // count its length.
    if (is_1.isString(offset))
        offset = offset.length;
    char = char || ' ';
    var pad = '';
    while (len--) {
        pad += char;
    }
    if (offset)
        return padLeft('', offset, null, char) + pad + val;
    return pad + val;
}