RockLobsterInc\Swv

count_code_units() │ CF7 1.0

Returns the number of code units in a string.

Хуков нет.

Возвращает

int|false. The number of code units, or false if mbstring is not available.

Использование

count_code_units( $input ): int|bool;
$input(строка) (обязательный)
Input string in the UTF-8 encoding.

Код count_code_units() CF7 6.2.4.1

function count_code_units(string $input): int|bool
{
    if (!extension_loaded("mbstring")) {
        return false;
    }

    if ("" === $input) {
        return 0;
    }

    $input = canonicalize_newline($input);
    $input = mb_convert_encoding($input, "UTF-16", "UTF-8");

    return intdiv(mb_strlen($input, "8bit"), 2);
}