_canonical_charset

函数


_canonical_charset ( $charset )
Access
Private
参数
  • (string)
    $charset
    A charset name.
    Required:
返回值
  • (string) The canonical form of the charset.
相关
  • https://core.trac.wordpress.org/ticket/23688
定义位置
  • wp-includes/functions.php
    , line 7213
引入
3.6.0
弃用

检索所提供的字符集的规范形式,适合传递给PHP函数,如htmlspecialchars()和charset HTML属性。

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