_canonical_charset

The timeline below displays how wordpress function _canonical_charset has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Retrieves a canonical form of the provided charset appropriate for passing to PHP
 * functions such as htmlspecialchars() and charset HTML attributes.
 *
 * @since 3.6.0
 * @access private
 *
 * @see https://core.trac.wordpress.org/ticket/23688
 *
 * @param string $charset A charset name.
 * @return string The canonical form of the charset.
 */
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;
}

WordPress Version: 5.5

/**
 * Retrieve a canonical form of the provided charset appropriate for passing to PHP
 * functions such as htmlspecialchars() and charset HTML attributes.
 *
 * @since 3.6.0
 * @access private
 *
 * @see https://core.trac.wordpress.org/ticket/23688
 *
 * @param string $charset A charset name.
 * @return string The canonical form of the charset.
 */
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;
}

WordPress Version: 4.7

/**
 * Retrieve a canonical form of the provided charset appropriate for passing to PHP
 * functions such as htmlspecialchars() and charset html attributes.
 *
 * @since 3.6.0
 * @access private
 *
 * @see https://core.trac.wordpress.org/ticket/23688
 *
 * @param string $charset A charset name.
 * @return string The canonical form of the charset.
 */
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;
}

WordPress Version: 4.1

/**
 * Retrieve a canonical form of the provided charset appropriate for passing to PHP
 * functions such as htmlspecialchars() and charset html attributes.
 *
 * @since 3.6.0
 * @access private
 *
 * @see https://core.trac.wordpress.org/ticket/23688
 *
 * @param string $charset A charset name.
 * @return string The canonical form of the charset.
 */
function _canonical_charset($charset)
{
    if ('UTF-8' === $charset || 'utf-8' === $charset || 'utf8' === $charset || 'UTF8' === $charset) {
        return 'UTF-8';
    }
    if ('ISO-8859-1' === $charset || 'iso-8859-1' === $charset || 'iso8859-1' === $charset || 'ISO8859-1' === $charset) {
        return 'ISO-8859-1';
    }
    return $charset;
}

WordPress Version: 4.0

/**
 * Retrieve a canonical form of the provided charset appropriate for passing to PHP
 * functions such as htmlspecialchars() and charset html attributes.
 *
 * @since 3.6.0
 * @access private
 *
 * @see http://core.trac.wordpress.org/ticket/23688
 *
 * @param string $charset A charset name.
 * @return string The canonical form of the charset.
 */
function _canonical_charset($charset)
{
    if ('UTF-8' === $charset || 'utf-8' === $charset || 'utf8' === $charset || 'UTF8' === $charset) {
        return 'UTF-8';
    }
    if ('ISO-8859-1' === $charset || 'iso-8859-1' === $charset || 'iso8859-1' === $charset || 'ISO8859-1' === $charset) {
        return 'ISO-8859-1';
    }
    return $charset;
}

WordPress Version: 3.7

/**
 * Return a canonical form of the provided charset appropriate for passing to PHP
 * functions such as htmlspecialchars() and charset html attributes.
 *
 * @link http://core.trac.wordpress.org/ticket/23688
 * @since 3.6.0
 *
 * @param string A charset name
 * @return string The canonical form of the charset
 */
function _canonical_charset($charset)
{
    if ('UTF-8' === $charset || 'utf-8' === $charset || 'utf8' === $charset || 'UTF8' === $charset) {
        return 'UTF-8';
    }
    if ('ISO-8859-1' === $charset || 'iso-8859-1' === $charset || 'iso8859-1' === $charset || 'ISO8859-1' === $charset) {
        return 'ISO-8859-1';
    }
    return $charset;
}