_canonical_charset( string $charset ): string
- Since
- 3.6.0
- Source
wp-includes/functions.php:7603
Retrieves a canonical form of the provided charset appropriate for passing to PHP functions such as htmlspecialchars() and charset HTML attributes.
Parameters
$charsetstring- A charset name, e.g. "UTF-8", "Windows-1252", "SJIS".
Return
string- The canonical form of the charset.
Uses · 1
- is_utf8_charset()Indicates if a given slug for a character set represents the UTF-8 text encoding. If not provided, examines the current blog's charset.
Used by · 2
- _wp_die_process_input()Processes arguments passed to wp_die() consistently for its handlers.
- _wp_specialchars()Converts a number of special characters into their HTML entities.
Source
function _canonical_charset( $charset ) { if ( is_utf8_charset( $charset ) ) { return 'UTF-8'; } /* * Normalize the ISO-8859-1 family of languages. * * This is not required for htmlspecialchars(), as it properly recognizes all of * the input character sets that here are transformed into "ISO-8859-1". * * @todo Should this entire check be removed since it's not required for the stated purpose? * @todo Should WordPress transform other potential charset equivalents, such as "latin1"? */ if ( ( 0 === strcasecmp( 'iso-8859-1', $charset ) ) || ( 0 === strcasecmp( 'iso8859-1', $charset ) ) ) { return 'ISO-8859-1'; } return $charset;}History
Introduced in 3.6.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-includes/functions.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.