<?php
function strLenU(string $s): int {
return mb_strlen($s, 'UTF-8');
}
function subStrU(string $s, int $start, ?int $len = null): string {
return $len === null
? mb_substr($s, $start, null, 'UTF-8')
: mb_substr($s, $start, $len, 'UTF-8');
}
function strPosU(string $haystack, string $needle, int $offset = 0): int|false {
return mb_strpos($haystack, $needle, $offset, 'UTF-8');
}
// Strict UTF-8 → fixed string, or false on invalid bytes.
function ensureUtf8(string $s): string|false {
return mb_check_encoding($s, 'UTF-8') ? $s : false;
}
Create a free account and build your private vault. Share publicly whenever you want.