:param value: value to encode
766942
def encode(self, value):
        '''
        
        '''
        kassert.is_of_types(value, Bits)
        if len(value) % 8 != 0:
            raise KittyException('this encoder cannot encode bits that are not byte aligned')
        return self._encoder.encode(value.bytes)
962944
def to_representation(self, value):
        
        return {
            six.text_type(key): self.child.to_representation(val)
            for key, val in value.items()
        }
1172188
def encode(cls, value):
        
        try:
            if float(value) + 0 == value:
                return repr(value)
        except (TypeError, ValueError):
            pass

        raise InvalidValue('not a float')
1362501
def set(self, value):
        

        if not isinstance(value, str_cls):
            raise TypeError(unwrap(
                '''
                %s value must be a unicode string, not %s
                ''',
                type_name(self),
                type_name(value)
            ))

        self._native = value

        if self._map is not None:
            if value in self._reverse_map:
                value = self._reverse_map[value]

        self.contents = b''
        first = None
        for index, part in enumerate(value.split('.')):
            part = int(part)

            # The first two parts are merged into a single byte
            if index == 0:
                first = part
                continue
            elif index == 1:
                part = (first * 40) + part

            encoded_part = chr_cls(0x7F & part)
            part = part >> 7
            while part > 0:
                encoded_part = chr_cls(0x80 | (0x7F & part)) + encoded_part
                part = part >> 7
            self.contents += encoded_part

        self._header = None
        if self._trailer != b'':
            self._trailer = b''
522677
def encode(value, encoding='utf-8', encoding_errors='strict'):
    
    if isinstance(value, bytes):
        return value
    if not isinstance(value, basestring):
        value = str(value)
    if isinstance(value, unicode):
        value = value.encode(encoding, encoding_errors)
    return value
721680
public final Object encode(Object value) {
      if (value == null) {
         return null;
      }
      if (value instanceof Val) {
         return encodeImpl(Cast.<Val>as(value).get());
      }
      return encodeImpl(value);
   }
727329
def encode(self, value):
        
        opcode = self.cmddict[value].opcode
        return super(CmdType, self).encode(opcode)
965003
def stringify_value(value):
    
    if value is None:
        return u''
    isoformat = getattr(value, 'isoformat', None)
    if isoformat is not None:
        value = isoformat()
    return type(u'')(value)
217541
def encode(cls, value):
        
        coerced = unicode(value)
        if coerced == value:
            return coerced.encode(cls._encoding)

        raise InvalidValue('not text')
846704
public static String encodeString(String value) {
    if (value == null) {
      return null;
    }
    StringBuilder encoded = new StringBuilder();
    int len = value.length();
    for (int i = 0; i < len; i++) {
      char c = value.charAt(i);
      switch (c) {
        case ARRAY_DELIMITER_CHAR:
        case KEY_VALUE_DELIMITER_CHAR:
        case ESCAPE_CHAR:
          encoded.append(ESCAPE_CHAR);
          break;
        default:
          // just append char
      }
      encoded.append(c);
    }
    return encoded.toString();
  }
294479
def _value_encode(cls, member, value):
        
        try:
            field_validator = cls.fields[member]
        except KeyError:
            return cls.valueparse.encode(value)

        return field_validator.encode(value)
87539
def encode(cls, value):
        
        try:
            coerced = [str(v) for v in value]
            if coerced == value:
                return ",".join(coerced).encode(cls._encoding) if len(
                    value) > 0 else None
        except TypeError:
            pass

        raise InvalidValue('not a list of strings')
379072
private static function encodeValue($value)
    {
        $value = gmp_strval($value);

        return Base64Url::encode(self::convertDecToBin($value));
    }
763560
function encode ( value, quotes ) {
	const shouldQuote = quotes.getValue();
	let resolvedValue = JSON.stringify(getJsonValueFromSassValue(value, { precision: this.options.precision }));
	if ( shouldQuote ) {
		resolvedValue = `'${resolvedValue}'`;
	}
	return new types.String(resolvedValue);
}
938598
def content(self, value):
        
        if isinstance(value, bytes):
            self._content = value
        else:
            self._content = value.encode(ENCODING)
        self.size = len(value)
1109671
def encode_with_ts(value)
      # Not sure if this object is thread-safe, so we re-create
      # each time. 

      public_key = OpenSSL::PKey::RSA.new(self.public_key_str)

      payload = "#{value}|#{self.now_timestamp}"

      return Base64.encode64(public_key.public_encrypt(payload))
    end
19960
def value_to_db(self, value):
        
        if isinstance(value, six.string_types):
            value = value.encode("utf_8")
        return value