Fix character encoding detection in CSV exporter for PHP 8.1 (#38648)
This commit is contained in:
commit
902454a40c
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: fix
|
||||||
|
|
||||||
|
Fix character encoding detection in CSV exporter for PHP 8.1
|
|
@ -398,8 +398,10 @@ abstract class WC_CSV_Exporter {
|
||||||
$use_mb = function_exists( 'mb_convert_encoding' );
|
$use_mb = function_exists( 'mb_convert_encoding' );
|
||||||
|
|
||||||
if ( $use_mb ) {
|
if ( $use_mb ) {
|
||||||
$encoding = mb_detect_encoding( $data, 'UTF-8, ISO-8859-1', true );
|
$is_valid_utf_8 = mb_check_encoding( $data, 'UTF-8' );
|
||||||
$data = 'UTF-8' === $encoding ? $data : utf8_encode( $data );
|
if ( ! $is_valid_utf_8 ) {
|
||||||
|
$data = mb_convert_encoding( $data, 'UTF-8', 'ISO-8859-1' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->escape_data( $data );
|
return $this->escape_data( $data );
|
||||||
|
|
Loading…
Reference in New Issue