_is_utf8_charset()
Indicates if a given slug for a character set represents the UTF-8 text encoding.
A charset is considered to represent UTF-8 if it is a case-insensitive match of "UTF-8" with or without the hyphen.
Example:
true === _is_utf8_charset( 'UTF-8' ); true === _is_utf8_charset( 'utf8' ); false === _is_utf8_charset( 'latin1' ); false === _is_utf8_charset( 'UTF 8' );
// Only strings match. false === _is_utf8_charset( [ 'charset' => 'utf-8' ] );
is_utf8_charset should be used outside of this file.
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Returns
bool. Whether the slug represents the UTF-8 encoding.
Usage
_is_utf8_charset( $charset_slug );
- $charset_slug(string) (required)
- Slug representing a text character encoding, or "charset". E.g. "UTF-8", "Windows-1252", "ISO-8859-1", "SJIS".
Changelog
| Since 6.6.1 | Introduced. |
_is_utf8_charset() is utf8 charset code WP 7.1
function _is_utf8_charset( $charset_slug ) {
if ( ! is_string( $charset_slug ) ) {
return false;
}
return (
0 === strcasecmp( 'UTF-8', $charset_slug ) ||
0 === strcasecmp( 'UTF8', $charset_slug )
);
}