# _canonical_charset()

URL: https://chugunov.pro/api-wordpress/functions/_canonical_charset/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 3.6.0.

## Сигнатура

```php
_canonical_charset( string $charset ): string
```

## Описание

Смотрите такжеhttps://core.trac.wordpress.org/ticket/23688

## Параметры

- `$charset` `string` — обязательный. Имя кодировки, например «UTF-8», «Windows-1252», «SJIS».

## Возвращаемое значение

`string`

## Исходный код

Файл: `wp-includes/functions.php:7641`

```php
function _canonical_charset( $charset ) {
	if ( is_utf8_charset( $charset ) ) {
		return 'UTF-8';
	}

	/*
	 * Normalize the ISO-8859-1 family of languages.
	 *
	 * This is not required for htmlspecialchars(), as it properly recognizes all of
	 * the input character sets that here are transformed into "ISO-8859-1".
	 *
	 * @todo Should this entire check be removed since it's not required for the stated purpose?
	 * @todo Should WordPress transform other potential charset equivalents, such as "latin1"?
	 */
	if (
		( 0 === strcasecmp( 'iso-8859-1', $charset ) ) ||
		( 0 === strcasecmp( 'iso8859-1', $charset ) )
	) {
		return 'ISO-8859-1';
	}

	return $charset;
}
```

## История изменений

- 3.6.0 — Introduced.

## Связанные

Использует: [`is_utf8_charset`](https://chugunov.pro/api-wordpress/functions/is_utf8_charset/).
Используется в: [`_wp_die_process_input`](https://chugunov.pro/api-wordpress/functions/_wp_die_process_input/), [`wp_die`](https://chugunov.pro/api-wordpress/functions/wp_die/), [`_wp_specialchars`](https://chugunov.pro/api-wordpress/functions/_wp_specialchars/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/_canonical_charset/
