Title: is_utf8_charset
Published: July 16, 2024
Last modified: May 20, 2026

---

# is_utf8_charset( string|null $blog_charset = null ): bool

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/is_utf8_charset/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/is_utf8_charset/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/is_utf8_charset/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/is_utf8_charset/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/is_utf8_charset/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/is_utf8_charset/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/is_utf8_charset/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/is_utf8_charset/?output_format=md#wp--skip-link--target)

Indicates if a given slug for a character set represents the UTF-8 text encoding.
If not provided, examines the current blog’s charset.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/is_utf8_charset/?output_format=md#description)󠁿

A charset is considered to represent UTF-8 if it is a case-insensitive match of “
UTF-8” with or without the hyphen.

Example:

    ```php
    true  === is_utf8_charset( 'UTF-8' );
    true  === is_utf8_charset( 'utf8' );
    false === is_utf8_charset( 'latin1' );
    false === is_utf8_charset( 'UTF 8' );

    // Only strings match.
    false === is_utf8_charset( [ 'charset' => 'utf-8' ] );

    // Without a given charset, it depends on the site option "blog_charset".
    $is_utf8 = is_utf8_charset();
    ```

### 󠀁[See also](https://developer.wordpress.org/reference/functions/is_utf8_charset/?output_format=md#see-also)󠁿

 * _is_utf8_charset

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/is_utf8_charset/?output_format=md#parameters)󠁿

 `$blog_charset`string|nulloptional

Slug representing a text character encoding, or "charset".
 E.g. "UTF-8", "Windows-
1252", "ISO-8859-1", "SJIS". Default value is to infer from "blog_charset" option.

Default:`null`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/is_utf8_charset/?output_format=md#return)󠁿

 bool Whether the slug represents the UTF-8 encoding.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/is_utf8_charset/?output_format=md#source)󠁿

    ```php
    function is_utf8_charset( $blog_charset = null ) {
    	return _is_utf8_charset( $blog_charset ?? get_option( 'blog_charset' ) );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/functions.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/functions.php#L7625)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/functions.php#L7625-L7627)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/is_utf8_charset/?output_format=md#related)󠁿

| Uses | Description | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  |

| Used by | Description | 
| [WP_Script_Modules::print_script_module_data()](https://developer.wordpress.org/reference/classes/wp_script_modules/print_script_module_data/)`wp-includes/class-wp-script-modules.php` |

Print data associated with Script Modules.

  | 
| [wp_check_invalid_utf8()](https://developer.wordpress.org/reference/functions/wp_check_invalid_utf8/)`wp-includes/formatting.php` |

Checks for invalid UTF8 in a string.

  | 
| [_canonical_charset()](https://developer.wordpress.org/reference/functions/_canonical_charset/)`wp-includes/functions.php` |

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

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/is_utf8_charset/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.6.1](https://developer.wordpress.org/reference/since/6.6.1/) | A wrapper for _is_utf8_charset | 
| [6.6.0](https://developer.wordpress.org/reference/since/6.6.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fis_utf8_charset%2F)
before being able to contribute a note or feedback.