Index: src/wp-includes/formatting.php
===================================================================
--- src/wp-includes/formatting.php	(revision 42640)
+++ src/wp-includes/formatting.php	(working copy)
@@ -1094,6 +1094,25 @@
 }
 
 /**
+ * Checks support for utf8 in the installed PCRE library.
+ *
+ * @since 5.0.0
+ *
+ * @staticvar bool $can
+ *
+ * @return bool True if installed PCRE library supports the `/u` flag.
+ */
+function wp_can_utf8_pcre() {
+	static $can = null;
+
+	if ( ! isset( $can ) ) {
+		$can = (bool) @preg_match( '/^./u', 'a' );
+	}
+
+	return $can;
+}
+
+/**
  * Checks for invalid UTF8 in a string.
  *
  * @since 2.8.0
@@ -1121,13 +1140,8 @@
 		return $string;
 	}
 
-	// Check for support for utf8 in the installed PCRE library once and store the result in a static
-	static $utf8_pcre = null;
-	if ( ! isset( $utf8_pcre ) ) {
-		$utf8_pcre = @preg_match( '/^./u', 'a' );
-	}
 	// We can't demand utf8 in the PCRE installation, so just return the string in those cases
-	if ( ! $utf8_pcre ) {
+	if ( ! wp_can_utf8_pcre() ) {
 		return $string;
 	}
 
