Index: src/wp-includes/wp-db.php
===================================================================
--- src/wp-includes/wp-db.php	(revision 32374)
+++ src/wp-includes/wp-db.php	(working copy)
@@ -2590,6 +2590,11 @@
 	protected function strip_invalid_text( $data ) {
 		$db_check_string = false;
 
+		$internal_encoding = false;
+		if ( function_exists( 'mb_internal_encoding' ) ) {
+			$internal_encoding = mb_internal_encoding();
+		}
+
 		foreach ( $data as &$value ) {
 			$charset = $value['charset'];
 
@@ -2636,7 +2641,7 @@
 			}
 
 			// utf8 can be handled by regex, which is a bunch faster than a DB lookup.
-			if ( ( 'utf8' === $charset || 'utf8mb3' === $charset || 'utf8mb4' === $charset ) && function_exists( 'mb_strlen' ) ) {
+			if ( ( 'utf8' === $charset || 'utf8mb3' === $charset || 'utf8mb4' === $charset ) && 'UTF-8' === $internal_encoding && function_exists( 'mb_strlen' ) ) {
 				$regex = '/
 					(
 						(?: [\x00-\x7F]                  # single-byte sequences   0xxxxxxx
