Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness. Use https://core.trac.wordpress.org/ticket/23688 instead.

_canonical_charset() WordPress Function

The canonical_charset() function is used to retrieve the charset used for the current page. This is useful for plugins and themes that need to know the charset used by the current page.

_canonical_charset( string $charset ) #

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


Description

Top ↑

See also


Top ↑

Parameters

$charset

(string)(Required)A charset name.


Top ↑

Return

(string) The canonical form of the charset.


Top ↑

Source

File: wp-includes/functions.php

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;
}


Top ↑

Changelog

Changelog
VersionDescription
3.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More