2121 * Example:
2222 *
2323 * // Quoted forms have non-printable ASCII encoded as octets.
24- * 'this is some text' === rfc2047_decode ( '=?iso-8859-1?q?this=20is_some=20text?=' );
25- * '👌' === rfc2047_decode ( '=?utf-8?q?=F0=9F=91=8C?=' );
24+ * 'this is some text' === wp_decode_rfc2047 ( '=?iso-8859-1?q?this=20is_some=20text?=' );
25+ * '👌' === wp_decode_rfc2047 ( '=?utf-8?q?=F0=9F=91=8C?=' );
2626 *
2727 * // Binary forms are base64-encoded.
28- * '👌' === rfc2047_decode ( '=?utf-8?B??=8J+RjA==?=' );
29- * 'םולש ןב ילטפנ' === rfc2047_decode ( '=?iso-8859-8?b?7eXs+SDv4SDp7Oj08A==?=' );
28+ * '👌' === wp_decode_rfc2047 ( '=?utf-8?B??=8J+RjA==?=' );
29+ * 'םולש ןב ילטפנ' === wp_decode_rfc2047 ( '=?iso-8859-8?b?7eXs+SDv4SDp7Oj08A==?=' );
3030 *
3131 * // Character sets are re-encoded into UTF-8
32- * '100¥' === rfc2047_decode ( '=?iso-8859-1?Q?500=A5?=' );
33- * '🏴' === rfc2047_decode ( '=?GB-18030?Q?=949=C82=D36=A01=D36=9F6=D36=9F9=D36=A08=D36=A01=D36=A25?=' );
32+ * '100¥' === wp_decode_rfc2047 ( '=?iso-8859-1?Q?500=A5?=' );
33+ * '🏴' === wp_decode_rfc2047 ( '=?GB-18030?Q?=949=C82=D36=A01=D36=9F6=D36=9F9=D36=A08=D36=A01=D36=A25?=' );
3434 *
3535 * // Linear white-space is collapsed.
36- * 'ab c d e' === rfc2047_decode ( '=?ASCII?Q?a?= =?ASCII?Q?b?= c d=?ASCII?Q?=20?==?ASCII?Q?e?=' )
36+ * 'ab c d e' === wp_decode_rfc2047 ( '=?ASCII?Q?a?= =?ASCII?Q?b?= c d=?ASCII?Q?=20?==?ASCII?Q?e?=' )
3737 *
3838 * // Error-handling is up to the call site.
39- * '=?UTF-8?Q?=6f?=' === rfc2047_decode ( '=?UTF-8?Q?=6f?=' );
40- * '=?UTF-8?Q?=6f?=' === rfc2047_decode ( '=?UTF-8?Q?=6f?=', 'preserve-errors' );
41- * '�' === rfc2047_decode ( '=?UTF-8?Q?=6f?=', 'replace-errors' );
42- * null === rfc2047_decode ( '=?UTF-8?Q?=6f?=', 'bail-on-error' );
39+ * '=?UTF-8?Q?=6f?=' === wp_decode_rfc2047 ( '=?UTF-8?Q?=6f?=' );
40+ * '=?UTF-8?Q?=6f?=' === wp_decode_rfc2047 ( '=?UTF-8?Q?=6f?=', 'preserve-errors' );
41+ * '�' === wp_decode_rfc2047 ( '=?UTF-8?Q?=6f?=', 'replace-errors' );
42+ * null === wp_decode_rfc2047 ( '=?UTF-8?Q?=6f?=', 'bail-on-error' );
4343 *
4444 * // Invalid character encodings are errors.
45- * null === rfc2047_decode ( '=?UTF-8?Q?=C0?=', 'bail-on-error' );
45+ * null === wp_decode_rfc2047 ( '=?UTF-8?Q?=C0?=', 'bail-on-error' );
4646 *
4747 * @see https://www.rfc-editor.org/rfc/rfc2047
4848 *
5353 * Default is to preserve invalid encoded words as plaintext.
5454 * @return string Decoded string in UTF-8, if supported, else `null`.
5555 */
56- function rfc2047_decode ( $ encoded , $ errors = 'preserve-errors ' ) {
56+ function wp_decode_rfc2047 ( $ encoded , $ errors = 'preserve-errors ' ) {
5757 /**
5858 * {@see iconv_mime_decode()} which does not give control over error-handling
59- * at the granularity necessary for this decoder..
59+ * at the granularity necessary for this decoder.
6060 */
6161
6262 $ decoded = '' ;
@@ -237,7 +237,7 @@ function ( $matches ) use ( &$failed_decode ) {
237237 }
238238
239239 // Verify the encoding.
240- if ( false === $ decoded_chunk || ! seems_utf8 ( $ decoded_chunk ) ) {
240+ if ( false === $ decoded_chunk || ! wp_is_valid_utf8 ( $ decoded_chunk ) ) {
241241 goto handle_invalid;
242242 }
243243
0 commit comments