_canonical_charset()WP 3.6.0

Retrieves a canonical form of the provided charset appropriate for passing to PHP functions such as htmlspecialchars() and charset HTML attributes.

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.

Return

String. The canonical form of the charset.

Usage

_canonical_charset( $charset );
$charset(string) (required)
A charset name.

Notes

Changelog

Since 3.6.0 Introduced.

_canonical_charset() code WP 6.5.4

function _canonical_charset( $charset ) {
	if ( 'utf-8' === strtolower( $charset ) || 'utf8' === strtolower( $charset ) ) {

		return 'UTF-8';
	}

	if ( 'iso-8859-1' === strtolower( $charset ) || 'iso8859-1' === strtolower( $charset ) ) {

		return 'ISO-8859-1';
	}

	return $charset;
}