WP_HTML_Decoder::code_point_to_utf8_bytes │ public static │ WP 6.6.0

Encode a code point number into the UTF-8 encoding.

This encoder implements the UTF-8 encoding algorithm for converting a code point into a byte sequence. If it receives an invalid code point it will return the Unicode Replacement Character U+FFFD �.

Example:

'🅰' === WP_HTML_Decoder::code_point_to_utf8_bytes( 0x1f170 );
// Half of a surrogate pair is an invalid code point.
'�' === WP_HTML_Decoder::code_point_to_utf8_bytes( 0xd83c );

Метод класса: WP_HTML_Decoder{}

Хуков нет.

Возвращает

string. Converted code point, or � if invalid.

Использование

$result = WP_HTML_Decoder::code_point_to_utf8_bytes( $code_point ): string;
$code_point(int) (обязательный)
Which code point to convert.

Заметки

Смотрите: https://www.rfc-editor.org/rfc/rfc3629 For the UTF-8 standard.

Список изменений

С версии 6.6.0 Введена.

Код WP_HTML_Decoder::code_point_to_utf8_bytes() WP 7.1.4

public static function code_point_to_utf8_bytes( $code_point ): string {
	$string = mb_chr( $code_point, 'UTF-8' );

	return false !== $string ? $string : '�';
}