WP_HTML_Decoder::code_point_to_utf8_bytes
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 );
Method of the class: WP_HTML_Decoder{}
No Hooks.
Returns
string. Converted code point, or � if invalid.
Usage
$result = WP_HTML_Decoder::code_point_to_utf8_bytes( $code_point ): string;
- $code_point(int) (required)
- Which code point to convert.
Notes
| See: https://www.rfc-editor.org/rfc/rfc3629 For the UTF-8 standard. |
Changelog
| Since 6.6.0 | Introduced. |
WP_HTML_Decoder::code_point_to_utf8_bytes() WP HTML Decoder::code point to utf8 bytes code WP 7.1
public static function code_point_to_utf8_bytes( $code_point ): string {
$string = mb_chr( $code_point, 'UTF-8' );
return false !== $string ? $string : '�';
}