|
mb_scrubReplace ill-formed byte sequences with the substitute character Description
string mb_scrub(string
$string, stringnull $encoding = null)Perform a character set conversion from the specified encoding, or the default encoding if no encoding was specified, to the same encoding. This has the effect of replacing any invalid byte sequences with the substitute character. Parameters
Return ValuesThe string result with invalid byte sequences replaced. Errors/Exceptions
As of PHP 8.0.0, a ValueError is thrown if
Changelog
ExamplesExample #1 Byte-level replacement performed by mb_scrub bin2hex is used here because terminals, browsers and fonts may render an ill-formed byte sequence with a replacement character of their own, which hides what the string actually contains. The above example will output: 41ff42 413f42 41efbfbd42 Example #2 Using mb_scrub before UTF-8 aware processing
PCRE patterns using the The above example will output: bool(false) Malformed UTF-8 characters, possibly incorrectly encoded int(3) See Also
|