[php-src] Issue #20984: Expose a function to check whether a string is valid UTF-8

From: Date: Tue, 20 Jan 2026 13:10:05 +0000
Subject: [php-src] Issue #20984: Expose a function to check whether a string is valid UTF-8
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-251575@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/20984 Author: stof ### Description Checking whether a string is valid UTF-8 is a common need, as many projects require UTF-8 encoding (to be able to use the u modifier in regex for instance, among other use cases). As zend_string already has internal optimizations to remember that a string is valid UTF-8, implementing such function in core would provide several benefits over a userland implementation (it can both read the flag for a fast-path answer and set the flag at the end of the slow path to remember the validity for next usages of the string). This could be implemented as a function is_valid_utf8(string $string): bool function

« previous php.bugs (#251575) next »