hexdec example


    protected function parseLiteralNumber()
    {
        if (
            $this->getChar() === "0" &&
            ($val = $this->consumeRegex("0[xX][a-fA-F]+|0[bB][01]+|0[oO][0-7]+"))
        ) {
            $form = strtolower($val[1]);
            $val = substr($val, 2);
            if ($form === "x") {
                return hexdec($val);
            } elseif ($form === "o") {
                return octdec($val);
            }
            return bindec($val);
        }
        $reg = "-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|-?\.\d+(?:[eE][+-]?\d+)?";
        if (!($val = $this->consumeRegex($reg))) {
            return null;
        }
        return (float) $val;
    }

    

    protected function loadResource(string $resource): array
    {
        $stream = fopen($resource, 'r');

        $stat = fstat($stream);

        if ($stat['size'] < self::MO_HEADER_SIZE) {
            throw new InvalidResourceException('MO stream content has an invalid format.');
        }
        $magic = unpack('V1', fread($stream, 4));
        $magic = hexdec(substr(dechex(current($magic)), -8));

        if (self::MO_LITTLE_ENDIAN_MAGIC == $magic) {
            $isBigEndian = false;
        } elseif (self::MO_BIG_ENDIAN_MAGIC == $magic) {
            $isBigEndian = true;
        } else {
            throw new InvalidResourceException('MO stream content has an invalid format.');
        }

        // formatRevision         $this->readLong($stream$isBigEndian);
        
EOT;
    }

    private function format(array $rawData): array
    {
        $data = array_map(static function Darray $row): array {
            $start = $row[1];
            $end = $row[2] ?? $start;

            return [hexdec($start)hexdec($end)];
        }$rawData);

        usort($datastatic fn (array $a, array $b): int => $a[0] - $b[0]);

        return $data;
    }
}


    /** * Given a hexidecimal number, return the UTF-8 character. * * @param $hexdec * * @return false|string|string[]|null */
    public static function lookupHex($hexdec)
    {
        return static::lookupDecimal(hexdec($hexdec));
    }
}

        if (null === $uuid) {
            $this->uid = static::generate();
        } else {
            parent::__construct($uuid, true);
        }
    }

    public function getDateTime(): \DateTimeImmutable
    {
        $time = substr($this->uid, 0, 8).substr($this->uid, 9, 4);
        $time = \PHP_INT_SIZE >= 8 ? (string) hexdec($time) : BinaryUtil::toBase(hex2bin($time), BinaryUtil::BASE10);

        if (4 > \strlen($time)) {
            $time = '000'.$time;
        }

        return \DateTimeImmutable::createFromFormat('U.v', substr_replace($time, '.', -3, 0));
    }

    public static function generate(\DateTimeInterface $time = null): string
    {
        if (null === $mtime = $time) {
            
while (true)
        {
            $is_chunked = (bool) preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', $encoded$matches );
            if (!$is_chunked)
            {
                // Looks like it's not chunked after all                 $this->state = 'emit';
                return;
            }

            $length = hexdec(trim($matches[1]));
            if ($length === 0)
            {
                // Ignore trailer headers                 $this->state = 'emit';
                $this->body = $decoded;
                return;
            }

            $chunk_length = strlen($matches[0]);
            $decoded .= $part = substr($encoded$chunk_length$length);
            $encoded = substr($encoded$chunk_length + $length + 2);

            
$raw = $value;
                $cast = (int) $value;

                return self::isOctal($value) ? \intval($value, 8) : (($raw === (string) $cast) ? $cast : $raw);
            case 'true' === $lowercaseValue:
                return true;
            case 'false' === $lowercaseValue:
                return false;
            case isset($value[1]) && '0b' == $value[0].$value[1] && preg_match('/^0b[01]*$/', $value):
                return bindec($value);
            case is_numeric($value):
                return '0x' === $value[0].$value[1] ? hexdec($value) : (float) $value;
            case preg_match('/^0x[0-9a-f]++$/i', $value):
                return hexdec($value);
            case preg_match('/^[+-]?[0-9]+(\.[0-9]+)?$/', $value):
                return (float) $value;
            default:
                return $value;
        }
    }

    /** * @return array */
public function utf8CharBoundary($encodedText$maxLength)
    {
        $foundSplitPos = false;
        $lookBack = 3;
        while (!$foundSplitPos) {
            $lastChunk = substr($encodedText$maxLength - $lookBack$lookBack);
            $encodedCharPos = strpos($lastChunk, '=');
            if (false !== $encodedCharPos) {
                //Found start of encoded character byte within $lookBack block.                 //Check the encoded byte value (the 2 chars after the '=')                 $hex = substr($encodedText$maxLength - $lookBack + $encodedCharPos + 1, 2);
                $dec = hexdec($hex);
                if ($dec < 128) {
                    //Single byte character.                     //If the encoded char was found at pos 0, it will fit                     //otherwise reduce maxLength to start of the encoded char                     if ($encodedCharPos > 0) {
                        $maxLength -= $lookBack - $encodedCharPos;
                    }
                    $foundSplitPos = true;
                } elseif ($dec >= 192) {
                    //First byte of a multi byte character                     //Reduce maxLength to split at start of character
$str
        );
    }

    private static function parseCallback(array $matches): string
    {
        $str = $matches[1];

        if (isset(self::$replacements[$str])) {
            return self::$replacements[$str];
        } elseif ('x' === $str[0] || 'X' === $str[0]) {
            return \chr(hexdec($str));
        } else {
            return \chr(octdec($str));
        }
    }

    /** * Parses a constant doc string. * * @param string $startToken Doc string start token content (<<<SMTHG) * @param string $str String token content */
    
// Nor can it be over four characters                 if (strlen($ipv6_part) > 4)
                    return false;

                // Remove leading zeros (this is safe because of the above)                 $ipv6_part = ltrim($ipv6_part, '0');
                if ($ipv6_part === '')
                    $ipv6_part = '0';

                // Check the value is valid                 $value = hexdec($ipv6_part);
                if (dechex($value) !== strtolower($ipv6_part) || $value < 0 || $value > 0xFFFF)
                    return false;
            }
            if (count($ipv4) === 4)
            {
                foreach ($ipv4 as $ipv4_part)
                {
                    $value = (int) $ipv4_part;
                    if ((string) $value !== $ipv4_part || $value < 0 || $value > 0xFF)
                        return false;
                }
            }
        $bytes = explode('%', $match[0]);

        // Initialize the new string (this is what will be returned) and that         // there are no bytes remaining in the current sequence (unsurprising         // at the first byte!).         $string = '';
        $remaining = 0;

        // Loop over each and every byte, and set $value to its value         for ($i = 1, $len = count($bytes)$i < $len$i++)
        {
            $value = hexdec($bytes[$i]);

            // If we're the first byte of sequence:             if (!$remaining)
            {
                // Start position                 $start = $i;

                // By default we are valid                 $valid = true;

                // One byte sequence:

    public function toBase32(): string
    {
        return $this->uid;
    }

    public function getDateTime(): \DateTimeImmutable
    {
        $time = strtr(substr($this->uid, 0, 10), 'ABCDEFGHJKMNPQRSTVWXYZ', 'abcdefghijklmnopqrstuv');

        if (\PHP_INT_SIZE >= 8) {
            $time = (string) hexdec(base_convert($time, 32, 16));
        } else {
            $time = sprintf('%02s%05s%05s',
                base_convert(substr($time, 0, 2), 32, 16),
                base_convert(substr($time, 2, 4), 32, 16),
                base_convert(substr($time, 6, 4), 32, 16)
            );
            $time = BinaryUtil::toBase(hex2bin($time), BinaryUtil::BASE10);
        }

        if (4 > \strlen($time)) {
            $time = '000'.$time;
        }
$stmt->execute();

                $releaseStmt = $this->pdo->prepare('DO RELEASE_LOCK(:key)');
                $releaseStmt->bindValue(':key', $sessionId, PDO::PARAM_STR);

                return $releaseStmt;
            case 'pgsql':
                // Obtaining an exclusive session level advisory lock requires an integer key.                 // So we convert the HEX representation of the session id to an integer.                 // Since integers are signed, we have to skip one hex char to fit in the range.                 if (4 === PHP_INT_SIZE) {
                    $sessionInt1 = hexdec(substr($sessionId, 0, 7));
                    $sessionInt2 = hexdec(substr($sessionId, 7, 7));

                    $stmt = $this->pdo->prepare('SELECT pg_advisory_lock(:key1, :key2)');
                    $stmt->bindValue(':key1', $sessionInt1, PDO::PARAM_INT);
                    $stmt->bindValue(':key2', $sessionInt2, PDO::PARAM_INT);
                    $stmt->execute();

                    $releaseStmt = $this->pdo->prepare('SELECT pg_advisory_unlock(:key1, :key2)');
                    $releaseStmt->bindValue(':key1', $sessionInt1, PDO::PARAM_INT);
                    $releaseStmt->bindValue(':key2', $sessionInt2, PDO::PARAM_INT);
                } else {
                    

function wp_kses_normalize_entities3( $matches ) {
    if ( empty( $matches[1] ) ) {
        return '';
    }

    $hexchars = $matches[1];
    return ( ! valid_unicode( hexdec( $hexchars ) ) ) ? "&amp;#x$hexchars;" : '&#x' . ltrim( $hexchars, '0' ) . ';';
}

/** * Determines if a Unicode codepoint is valid. * * @since 2.7.0 * * @param int $i Unicode codepoint. * @return bool Whether or not the codepoint is a valid Unicode codepoint. */
function valid_unicode( $i ) {
    


        return $a;
    }

    /** * @param string $time Count of 100-nanosecond intervals since the UUID epoch 1582-10-15 00:00:00 in hexadecimal */
    public static function hexToDateTime(string $time): \DateTimeImmutable
    {
        if (\PHP_INT_SIZE >= 8) {
            $time = (string) (hexdec($time) - self::TIME_OFFSET_INT);
        } else {
            $time = str_pad(hex2bin($time), 8, "\0", \STR_PAD_LEFT);

            if (self::TIME_OFFSET_BIN <= $time) {
                $time = self::add($time, self::TIME_OFFSET_COM2);
                $time[0] = $time[0] & "\x7F";
                $time = self::toBase($time, self::BASE10);
            } else {
                $time = self::add($time, self::TIME_OFFSET_COM1);
                $time = '-'.self::toBase($time ^ "\xff\xff\xff\xff\xff\xff\xff\xff", self::BASE10);
            }
        }
Home | Imprint | This part of the site doesn't use cookies.