Skip to content

Commit 794e7cc

Browse files
committed
Detect and fix encoding of the database dump when importing
1 parent 15f8e0a commit 794e7cc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Import.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ public function parse_statements( $sql_file_path ) {
8080

8181
// phpcs:ignore
8282
while ( ( $line = fgets( $handle ) ) !== false ) {
83+
// Detect and convert encoding to UTF-8
84+
$detected_encoding = mb_detect_encoding( $line, mb_list_encodings(), true );
85+
if ( $detected_encoding && 'UTF-8' !== $detected_encoding ) {
86+
$line = mb_convert_encoding( $line, 'UTF-8', $detected_encoding );
87+
}
88+
8389
$line = trim( $line );
8490

8591
// Skip empty lines and comments

0 commit comments

Comments
 (0)