diff --git a/~dev_rating/application/classes/FileParser.php b/~dev_rating/application/classes/FileParser.php index ea5ea2fce7a439474844037b3aedb99f50133a8e..18df0d8063bb6ef2110c1c8bc41c22a0d3033e52 100644 --- a/~dev_rating/application/classes/FileParser.php +++ b/~dev_rating/application/classes/FileParser.php @@ -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; } }