Converts this field to binary (assuming it's a binary string)
346966
def binary_value(self):
        
        str_raw_value = str(self.raw_value)
        if len(str_raw_value) % 2 == 1:
            str_raw_value = '0' + str_raw_value

        return binascii.unhexlify(str_raw_value)
950185
def encode(self, value):
        '''
        
        '''
        encoded = strToBytes(value) + b'\x00'
        return Bits(bytes=encoded)
169257
def value(self):
        
        binary = UBInt8(self.sub_type).pack() + self.sub_value.pack()
        return BinaryData(binary)
203761
def decrypt_binary(self, binary, *args, **kwargs):
        
        return self.decrypt(binary, *args, **kwargs)
923578
def encode_to_bin(value):
    
    for char in value:
        for exp in EXP:
            if char & exp:
                yield True
            else:
                yield False
463052
def from_bin(cls, value):
        """"""
        value = value.lstrip('b')
        if len(value) == 32:
            return cls(int(value, 2))
        elif len(value) == 128:
            return cls(int(value, 2))
        else:
            return ValueError('%r: invalid binary notation' % (value,))
80427
def binary_encode_if_any_high_ascii(string)
      string = ensure_utf8(string)
      string.force_encoding('BINARY') if string.bytes.detect { |byte| byte > 127 }
      string
    end
396681
def _EncodeDateField(field, value):
    """"""
    if field.repeated:
        result = [d.isoformat() for d in value]
    else:
        result = value.isoformat()
    return encoding.CodecResult(value=result, complete=True)
367075
function convertRawBinary(rawColumnValue, column, context)
{
  // Ensure the format is valid.
  var format = context.format.toUpperCase();
  Errors.assertInternal(format === "HEX" || format === "BASE64");

  // Decode hex string sent by GS.
  var buffer = Buffer.from(rawColumnValue, "HEX");

  if (format === "HEX")
  {
    buffer.toStringSf = function()
    {
      // The raw value is already an uppercase hex string, so just return it.
      // Note that buffer.toString("HEX") returns a lowercase hex string, but we
      // want upper case.
      return rawColumnValue;
    }
  }
  else
  {
    buffer.toStringSf = function()
    {
      return this.toString("BASE64");
    }
  }

  buffer.getFormat = function()
  {
    return format;
  };

  return buffer;
}
200596
def to_bytes(value):
    
    if isinstance(value, text_type):
        return value.encode('utf-8')
    elif isinstance(value, ffi.CData):
        return ffi.string(value)
    elif isinstance(value, binary_type):
        return value
    else:
        raise ValueError('Value must be text, bytes, or char[]')
202492
@Nullable
  private static Object convertPrimitiveField(Group g, int fieldIndex, boolean binaryAsString)
  {
    PrimitiveType pt = (PrimitiveType) g.getType().getFields().get(fieldIndex);
    if (pt.isRepetition(Type.Repetition.REPEATED) && g.getFieldRepetitionCount(fieldIndex) > 1) {
      List<Object> vals = new ArrayList<>();
      for (int i = 0; i < g.getFieldRepetitionCount(fieldIndex); i++) {
        vals.add(convertPrimitiveField(g, fieldIndex, i, binaryAsString));
      }
      return vals;
    }
    return convertPrimitiveField(g, fieldIndex, 0, binaryAsString);
  }
1096132
def field_to_long(value):
        
        if isinstance(value, (int, long)):
            return long(value)
        elif isinstance(value, basestring):
            return bytes_to_long(from_hex(value))
        else:
            return None
525130
def _add_json_binary_field(b, serialized, field):
    ''' 
    '''
    try:
        val = b.decode("utf-8")
        serialized[field] = val
    except UnicodeDecodeError:
        val = utils.raw_urlsafe_b64encode(b).decode('utf-8')
        serialized[field + '64'] = val
1073312
def code_binary(item):
    
    code_str = code(item)
    if isinstance(code_str, six.string_types):
        return code_str.encode('utf-8')
    return code_str
866572
def ensure_binary_encoding(string)
      raise ArgumentError, "String is missing" if !string
      if string.encoding == Encoding::BINARY
        string
      else
        string.b
      end
    end
1299019
def to_binary(value, encoding='utf-8'):
    
    if not value:
        return b''
    if isinstance(value, six.binary_type):
        return value
    if isinstance(value, six.text_type):
        return value.encode(encoding)
    return to_text(value).encode(encoding)
616897
private void logBinaryStringInfo(StringBuilder binaryString) {

        encodeInfo += "Binary Length: " + binaryString.length() + "\n";
        encodeInfo += "Binary String: ";

        int nibble = 0;
        for (int i = 0; i < binaryString.length(); i++) {
            switch (i % 4) {
                case 0:
                    if (binaryString.charAt(i) == '1') {
                        nibble += 8;
                    }
                    break;
                case 1:
                    if (binaryString.charAt(i) == '1') {
                        nibble += 4;
                    }
                    break;
                case 2:
                    if (binaryString.charAt(i) == '1') {
                        nibble += 2;
                    }
                    break;
                case 3:
                    if (binaryString.charAt(i) == '1') {
                        nibble += 1;
                    }
                    encodeInfo += Integer.toHexString(nibble);
                    nibble = 0;
                    break;
            }
        }

        if ((binaryString.length() % 4) != 0) {
            encodeInfo += Integer.toHexString(nibble);
        }

        encodeInfo += "\n";
    }