_canonical_charset

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

Description

(string) _canonical_charset( (string) $charset ); 

Returns (string)

The canonical form of the charset.

Parameters (1)

0. $charset (string)
A charset name.

Usage

  1. if ( !function_exists( '_canonical_charset' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // A charset name. 
  5. $charset = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = _canonical_charset($charset); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function _canonical_charset( $charset ) { 
  2. if ( 'utf-8' === strtolower( $charset ) || 'utf8' === strtolower( $charset) ) { 
  3.  
  4. return 'UTF-8'; 
  5.  
  6. if ( 'iso-8859-1' === strtolower( $charset ) || 'iso8859-1' === strtolower( $charset ) ) { 
  7.  
  8. return 'ISO-8859-1'; 
  9.  
  10. return $charset;