Firstly, ANSI is not a type of character encoding. With ANSI, you need to find out what the encoding options are for the particular file that you're trying to read. First you should find out first if the file is already UTF-8 encoded, and if not, then simply encode it. Below, we check the encoding and if successful we return the file.
$output = false;
if( !mb_check_encoding( $myFile, 'UTF-8', true ) ):
$output = mb_convert_encoding( $myFile, 'UTF-8' );
endif;
Then simply check if the encoding worked.
return $output ? $output : 'Failed encoding file!';