Skip to content
Snippets Groups Projects
Commit a5b4893b authored by Andrew Rudenets's avatar Andrew Rudenets
Browse files

Added check the current encoding of the file

parent 8679f107
Branches
Tags
No related merge requests found
......@@ -109,6 +109,12 @@ class FileParser
public static function toUTF8($source_str) {
// TODO: make it able to convert from any encoding to UTF-8
return mb_convert_encoding($source_str, "utf-8", "windows-1251");
$enc = mb_detect_encoding($source_str, mb_list_encodings(), true);
if ($enc === false)
return $source_str;
else if ($enc !== "UTF-8")
return mb_convert_encoding($source_str, "utf-8", "windows-1251");
else
return $source_str;
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment