private static function _crockfordDecodeToIntStr($encodedStr, $encodedStrLen, $mapping) {
        // Try to use PHP's internal integer type.
        if (($encodedStrLen * 5 / 8) <= PHP_INT_SIZE) {
            $int = 0;
            for ($i = 0; $i < $encodedStrLen; $i++) {
                $int <<= 5;
                $int |= $mapping[$encodedStr[$i]];
            }
            if ($int >= 0)
                return $int;
        }

        // If we did not already return here, PHP's internal integer type can not
        // hold the encoded value. Now we use PHP's BC Math library instead and
        // return the integer as string.
        if (extension_loaded('bcmath')) {
            $intStr = '0';
            for ($i = 0; $i < $encodedStrLen; $i++) {
                $intStr = bcmul($intStr, '32', 0);
                $intStr = bcadd($intStr, (string) $mapping[$encodedStr[$i]], 0);
            }
            return $intStr;
        } else {
            throw new RuntimeException('BC Math functions are not available.', self::E_NO_BCMATH);
        }
    }