File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -148,7 +148,14 @@ public function parse_statements( $sql_file_path ) {
148148 */
149149 protected function execute_statements_with_ast_parser ( $ import_file ) {
150150 $ raw_queries = file_get_contents ( $ import_file );
151- $ parser = $ this ->driver ->create_parser ( $ raw_queries );
151+
152+ // Detect and convert encoding to UTF-8
153+ $ detected_encoding = mb_detect_encoding ( $ raw_queries , mb_list_encodings (), true );
154+ if ( $ detected_encoding && 'UTF-8 ' !== $ detected_encoding ) {
155+ $ raw_queries = mb_convert_encoding ( $ raw_queries , 'UTF-8 ' , $ detected_encoding );
156+ }
157+
158+ $ parser = $ this ->driver ->create_parser ( $ raw_queries );
152159 while ( $ parser ->next_query () ) {
153160 $ ast = $ parser ->get_query_ast ();
154161 $ statement = substr ( $ raw_queries , $ ast ->get_start (), $ ast ->get_length () );
You can’t perform that action at this time.
0 commit comments