Title: _wp_utf8_decode_fallback
Published: February 24, 2026
Last modified: August 20, 2026

---

# _wp_utf8_decode_fallback( string $utf8_text ): string

## In this article

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

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Converts a string from UTF-8 to ISO-8859-1, maintaining backwards compatibility 
with the deprecated function from the PHP standard library.

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

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

 * [utf8_decode()](https://developer.wordpress.org/reference/functions/utf8_decode/)

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

 `$utf8_text`stringrequired

Text treated as UTF-8 bytes.

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

 string Text converted into ISO-8859-1.

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

    ```php
    function _wp_utf8_decode_fallback( $utf8_text ) {
    	$utf8_text       = (string) $utf8_text;
    	$at              = 0;
    	$was_at          = 0;
    	$end             = strlen( $utf8_text );
    	$iso_8859_1_text = '';

    	while ( $at < $end ) {
    		// US-ASCII bytes are identical in ISO-8859-1 and UTF-8. These are 0x00–0x7F.
    		$ascii_byte_count = strspn(
    			$utf8_text,
    			"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" .
    			"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" .
    			" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f",
    			$at
    		);

    		if ( $ascii_byte_count > 0 ) {
    			$at += $ascii_byte_count;
    			continue;
    		}

    		$next_at        = $at;
    		$invalid_length = 0;
    		$found          = _wp_scan_utf8( $utf8_text, $next_at, $invalid_length, null, 1 );
    		$span_length    = $next_at - $at;
    		$next_byte      = '?';

    		if ( 1 !== $found ) {
    			if ( $invalid_length > 0 ) {
    				$next_byte = '';
    				goto flush_sub_part;
    			}

    			break;
    		}

    		// All convertible code points are two-bytes long.
    		$byte1 = ord( $utf8_text[ $at ] );
    		if ( 0xC0 !== ( $byte1 & 0xE0 ) ) {
    			goto flush_sub_part;
    		}

    		// All convertible code points are not greater than U+FF.
    		$byte2      = ord( $utf8_text[ $at + 1 ] );
    		$code_point = ( ( $byte1 & 0x1F ) << 6 ) | ( ( $byte2 & 0x3F ) );
    		if ( $code_point > 0xFF ) {
    			goto flush_sub_part;
    		}

    		$next_byte = chr( $code_point );

    		flush_sub_part:
    		$iso_8859_1_text .= substr( $utf8_text, $was_at, $at - $was_at );
    		$iso_8859_1_text .= $next_byte;
    		$at              += $span_length;
    		$was_at           = $at;

    		if ( $invalid_length > 0 ) {
    			$iso_8859_1_text .= '?';
    			$at              += $invalid_length;
    			$was_at           = $at;
    		}
    	}

    	if ( 0 === $was_at ) {
    		return $utf8_text;
    	}

    	$iso_8859_1_text .= substr( $utf8_text, $was_at );
    	return $iso_8859_1_text;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/compat-utf8.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/compat-utf8.php#L487)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/compat-utf8.php#L487-L558)

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

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

Finds spans of valid and invalid UTF-8 bytes in a given string.

  |

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

| Version | Description | 
| [6.9.0](https://developer.wordpress.org/reference/since/6.9.0/) | Introduced. |

## User Contributed Notes

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