WordPress at a glance
function is not described

wp_kses_normalize_entities() WP 1.0.0

Converts and fixes HTML entities.

This function normalizes HTML entities. It will convert AT&T to the correct AT&T, : to :, &#XYZZY; to &#XYZZY; and so on.

When $context is set to 'xml', HTML entities are converted to their code points. For example, AT&T…&#XYZZY; is converted to AT&T…&#XYZZY;.

No Hooks.


String. Content with normalized entities.


wp_kses_normalize_entities( $string, $context );
$string(string) (required)
Content to normalize entities.
Context for normalization. Can be either 'html' or 'xml'.
Default: 'html'


Since 1.0.0 Introduced.
Since 5.5.0 Added $context parameter.

Code of wp_kses_normalize_entities() WP 5.7.2

function wp_kses_normalize_entities( $string, $context = 'html' ) {
	// Disarm all entities by converting & to &amp;
	$string = str_replace( '&', '&amp;', $string );

	// Change back the allowed entities in our list of allowed entities.
	if ( 'xml' === $context ) {
		$string = preg_replace_callback( '/&amp;([A-Za-z]{2,8}[0-9]{0,2});/', 'wp_kses_xml_named_entities', $string );
	} else {
		$string = preg_replace_callback( '/&amp;([A-Za-z]{2,8}[0-9]{0,2});/', 'wp_kses_named_entities', $string );
	$string = preg_replace_callback( '/&amp;#(0*[0-9]{1,7});/', 'wp_kses_normalize_entities2', $string );
	$string = preg_replace_callback( '/&amp;#[Xx](0*[0-9A-Fa-f]{1,6});/', 'wp_kses_normalize_entities3', $string );

	return $string;