wppaste
WordPress

_canonical_charset( string $charset ): string

Since
3.6.0
Source
wp-includes/functions.php:7641
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

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.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 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.