function convert_to_utf8($str) { if (is_valid_utf8($str)) { return $str; } $pfx = substr($str, 0, 5000); if (substr_count($pfx, "\r") > 1.5 * substr_count($pfx, "\n")) { return mac_os_roman_to_utf8($str); } else { return windows_1252_to_utf8($str); } }
function convert_to_utf8($str) { if (substr_count(substr($str, 0, 5000), "\r") > 1.5 * substr_count(substr($str, 0, 5000), "\n")) { return mac_os_roman_to_utf8($str); } else { return windows_1252_to_utf8($str); } }