WordPress at a glance
function is not described

RandomCompat_substr() WP 1.0

substr() implementation that isn't brittle to mbstring.func_overload

This version uses mb_substr() in '8bit' mode to treat strings as raw binary rather than UTF-8, ISO-8859-1, etc

No Hooks.

Return

String.

Usage

RandomCompat_substr( $binary_string, $start, $length );
$binary_string(string) (required)
$start(int) (required)
$length(int)
(optional)
Default: null

Code of RandomCompat substr: wp-includes/random_compat/byte_safe_strings.php WP 5.2.2

<?php
function RandomCompat_substr($binary_string, $start, $length = null)
{
    if (!is_string($binary_string)) {
        throw new TypeError(
            'RandomCompat_substr(): First argument should be a string'
        );
    }

    if (!is_int($start)) {
        throw new TypeError(
            'RandomCompat_substr(): Second argument should be an integer'
        );
    }

    if ($length === null) {
        /**
         * mb_substr($str, 0, NULL, '8bit') returns an empty string on
         * PHP 5.3, so we have to find the length ourselves.
         */
        $length = RandomCompat_strlen($binary_string) - $start;
    } elseif (!is_int($length)) {
        throw new TypeError(
            'RandomCompat_substr(): Third argument should be an integer, or omitted'
        );
    }

    // Consistency with PHP's behavior
    if ($start === RandomCompat_strlen($binary_string) && $length === 0) {
        return '';
    }
    if ($start > RandomCompat_strlen($binary_string)) {
        return '';
    }

    return (string) mb_substr($binary_string, $start, $length, '8bit');
}

    } else {

/**
 * substr() implementation that isn't brittle to mbstring.func_overload
 *
 * This version just uses the default substr()
 *
 * @param string $binary_string
 * @param int $start
 * @param int $length (optional)
 *
 * @throws TypeError
 *
 * @return string
 */
function RandomCompat_substr($binary_string, $start, $length = null)
{
    if (!is_string($binary_string)) {
        throw new TypeError(
            'RandomCompat_substr(): First argument should be a string'
        );
    }

    if (!is_int($start)) {
        throw new TypeError(
            'RandomCompat_substr(): Second argument should be an integer'
        );
    }

    if ($length !== null) {
        if (!is_int($length)) {
            throw new TypeError(
                'RandomCompat_substr(): Third argument should be an integer, or omitted'
            );
        }

        return (string) substr($binary_string, $start, $length);
    }

    return (string) substr($binary_string, $start);
}