module training - enlarge the encoding checking
This commit is contained in:
parent
f62cf68e0a
commit
0361b2746a
@ -18,14 +18,8 @@ class CSVReader
|
||||
);
|
||||
|
||||
// if required, convert the file to the correct format
|
||||
$f = fopen($file_path, 'r');
|
||||
if ($f) {
|
||||
$line = fgets($f);
|
||||
$encoding = mb_detect_encoding($line, "UTF-8,ISO-8859-1", true);
|
||||
fclose($f);
|
||||
}
|
||||
|
||||
if ($encoding == 'ISO-8859-1') {
|
||||
$str = file_get_contents($file_path);
|
||||
if (mb_detect_encoding($str, "UTF-8,ISO-8859-1", true) == 'ISO-8859-1') {
|
||||
file_put_contents($file_path, utf8_encode(file_get_contents($file_path)));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user