, fixes * @date unknown, reviewed on 6 April 2005 */ function GetXMLEncode($file) { if (!($fp = fopen($file, "r"))) { echo "could not open XML input : $file"; } $fline = fgets($fp); // if some Windows special chars are found, return Windows encoding fseek($fp,0); $thefile=fread($fp,filesize($file)); if (strpos($thefile,'é') or strpos($thefile,'ë')) { return('windows-1252'); } // else get the string located between double quotes after string "ing=" (for "encoding") $match = array(); //initialize result var preg_match('/encoding="([0-9a-zA-Z-]*)"/i',$fline,$match); //find quoted encoding return $match[1]; // return with encoding type } ?>