Encode a 64 bits unsigned value ("uint64" type).

\param resource $value
GMP resource representing the 64 bits unsigned value
to encode.

\retval Encoder
Returns this encoder.
774557
public function encodeUint64($value)
    {
        $s = gmp_strval($value, 16);
        $s = str_pad($s, 16, '0', STR_PAD_LEFT);
        return $this->encodeBytes(pack('H*', $s));
    }
1175764
public function encode($value)
	{
		$type = gettype($value);
		if (!isset($this->typeEncoders[$type]))
		{
			throw new RuntimeException('Cannot encode ' . $type . ' value');
		}

		return $this->typeEncoders[$type]($value);
	}
278187
def encode(self, value):
        '''
        
        '''
        packed = pack(self.fmt, value)
        return Bits(bytes=packed)
815117
public function writeUInt64(int $value): self
    {
        $this->bytes .= Writer::bit64($value);

        return $this;
    }
890953
protected static function _encodeValue($value)
    {
        $string = '';

        switch (gettype($value))
        {
            case 'integer':
            case 'double':
                $string = $value;
                break;

            case 'boolean':
                $string = $value ? 'true' : 'false';
                break;

            case 'string':
                // Sanitize any CRLF characters..
                $string = '"' . str_replace(array("\r\n", "\n"), '\\n', $value) . '"';
                break;
        }

        return $string;
    }
320251
protected function convertToBytes($value)
    {
        $value = trim($value);
        $last  = strtolower($value[strlen($value) - 1]);

        switch ($last) {
            // The 'G' modifier is available since PHP 5.1.0
            case 'g':
                $value *= 1024;
                break;

            case 'm':
                $value *= 1024;
                break;

            case 'k':
                $value *= 1024;
                break;
        }

        return $value;
    }
1338125
function encodeUInt32(value) {
    let buffer = new ByteBuffer();
    if (value === null) {
        return buffer;
    }
    return buffer.writeVarint32(value);
}
1264267
public void writeRawLittleEndian64(final long value) throws IOException {
    writeRawByte((int)(value      ) & 0xFF);
    writeRawByte((int)(value >>  8) & 0xFF);
    writeRawByte((int)(value >> 16) & 0xFF);
    writeRawByte((int)(value >> 24) & 0xFF);
    writeRawByte((int)(value >> 32) & 0xFF);
    writeRawByte((int)(value >> 40) & 0xFF);
    writeRawByte((int)(value >> 48) & 0xFF);
    writeRawByte((int)(value >> 56) & 0xFF);
  }
285289
private function encode($value)
    {
        if ($value === true)
            $value = "true";
        else if ($value === false)
            $value = "false";
        else if (is_string($value))
            $value = "\"$value\"";
        return $value;
    }
672040
public static function vlqEncode($value)
    {
        static $VLQ_BASE_SHIFT, $VLQ_BASE, $VLQ_BASE_MASK, $VLQ_CONTINUATION_BIT, $BASE64_MAP;
        if (! $VLQ_BASE_SHIFT) {
            $VLQ_BASE_SHIFT = 5;
            $VLQ_BASE = 1 << $VLQ_BASE_SHIFT;
            $VLQ_BASE_MASK = $VLQ_BASE - 1;
            $VLQ_CONTINUATION_BIT = $VLQ_BASE;
            $BASE64_MAP = str_split('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/');
        }

        $vlq = $value < 0 ? ((-$value) << 1) + 1 : ($value << 1) + 0;

        $encoded = "";
        do {
            $digit = $vlq & $VLQ_BASE_MASK;
            $vlq >>= $VLQ_BASE_SHIFT;
            if ($vlq > 0) {
                $digit |= $VLQ_CONTINUATION_BIT;
            }
            $encoded .= $BASE64_MAP[$digit];

        } while ($vlq > 0);

        return $encoded;
    }
783659
public function base64($value, array $options, $mode) {
        if ($mode === self::TO && $options['encode']) {
            return base64_encode($value);
        }

        if ($mode === self::FROM && $options['decode']) {
            return base64_decode($value);
        }

        return $value;
    }
1099437
public function encodeMpint($value)
    {
        if (gmp_cmp($value, "0") == 0) {
            return $this->encodeString('');
        }
        $s = gmp_strval($value, 16);
        $s = pack('H*', str_pad($s, ((strlen($s) + 1) >> 1) << 1, '0', STR_PAD_LEFT));
        // Positive numbers where the most significant bit
        // in the first byte is set must be preceded with \x00
        // to distinguish them from negative numbers.
        if ((ord($s[0]) & 0x80) && gmp_sign($value) > 0) {
            $s = "\x00" . $s;
        }
        return $this->encodeString($s);
    }
158826
public static function FromValue( $value, $unsigned = false )
	{
		if ( is_object( $value ) || ( is_string( $value ) && ! is_numeric( $value ) ) || strpos( $value, "." ) !== false )
		{
			throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001, array( $value, "integer" ) );
		}

		$decimal = DecimalValue::FromValue( $value );

		if (
			( $unsigned && (
					$value < 0 ||
					$decimal->CompareTo( "18446744073709551615" ) == 1
				)
			) ||
			( ! $unsigned && (
					$decimal->CompareTo( (int)0x8000000000000000 ) == -1 ||
					$decimal->CompareTo( (int)0x7fffffffffffffff ) == 1
				)
			)
		)
		{
			throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001, array( $value, "integer" ) );
		}

		// if ( is_string( $value ) && ! is_numeric( $value ) ||
		// 	 ( ! $unsigned && (
		// 	 		$value < 0 ||
		// 	 		DecimalValue::FromValue( $value )->CompareTo( "18446744073709551615" ) == 1
		// 	 	)
		// 	 ) ||
		// 	 ( ! $unsigned && (
		// 	 		DecimalValue::FromValue( $value )->CompareTo( (int)0x8000000000000000 ) == -1 ||
		// 	 		DecimalValue::FromValue( $value )->CompareTo( (int)0x7fffffffffffffff ) == 1
		// 	 	)
		// 	 )
		// )
		// {
		// 	throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001, array( $value, "integer" ) );
		// }

		// if ( is_numeric( $value ) )
		// {
		// 	$value = round( $value );
		// }

		return new Long( $value );
	}
239580
public static function Base64Encode ($value, $options = []) {
		$to_encoding = isset($options['to_encoding']) ? $options['to_encoding'] : false;
		if ($to_encoding !== false) {
			$from_encoding = isset($options['from_encoding']) ? $options['from_encoding'] : static::DEFAULT_ENCODING;
			$value = mb_convert_encoding($value, $to_encoding, $from_encoding);
		}
		return base64_encode($value);
	}
1339207
public function encode($value) {
        $renderer = new Png();
        $renderer->setHeight($this->height);
        $renderer->setWidth($this->width);
        $qrCode = Encoder::encode($value, new ErrorCorrectionLevel($this->level), $this->encoding);
        $content = $renderer->render($qrCode);
        $this->image = imagecreatefromstring($content);
		return $this;
	}
529521
protected function serializeValue($value)
    {
        if ($this->isSerializable($value) === true) {
            // Activate default bit to detect serialization
            $value = serialize($value);
            $bytes = strlen($value);
            $flags = self::FLAG_DECIMAL_SERIALIZED;

        } else {
            // Real numbers should keep real numbers - Bit 2 = int , 3 = double/float
            if (is_int($value) === true) {
                $flags = self::FLAG_DECIMAL_INTEGER;

            } elseif (is_float($value) === true) {
                $flags = self::FLAG_DECIMAL_FLOAT;

            } elseif (is_string($value) === true) {
                // Never serialize strings! Otherwise append() & prepend() won't work!
                $flags = self::FLAG_DECIMAL_STRING;

            } elseif (is_bool($value) === true) {
                $value = strval($value);
                $flags = self::FLAG_DECIMAL_BOOLEAN;

            } else {
                throw new Exception(
                    sprintf('Unhandable value. Don\'t know how to process!')
                );
            }

            $bytes = strlen($value);
        }

        return array(
            'value' => $value,
            'flags' => $flags,
            'bytes' => $bytes,
        );
    }
1289475
public static function convertBytes($value)
    {
        if (is_numeric($value)) {
            return $value;
        }

        $value_length = \strlen($value);
        $qty = (int)substr($value, 0, $value_length - 1);
        $unit = Str::strtolower(substr($value, $value_length - 1));
        switch ($unit) {
            case 'k':
                $qty *= 1024;
                break;
            case 'm':
                $qty *= 1048576;
                break;
            case 'g':
                $qty *= 1073741824;
                break;
        }

        return $qty;
    }