You can change the default encoding like:
<?php
stream_default_encoding
"iso-8859-1" );
$str file_get_contents"somefile.txt"FILE_TEXT );
?>

Or use a specific context for a stream:
<?php
$ctxt 
stream_context_create(
    
NULL, array( 'encoding' => 'koi8-r' )
);
file_put_contents"someotherfile.txt"$dataFILE_TEXT$ctxt );
?>

Or set the encoding after opening a stream:
<?php
$f 
fopen"someotherfile.txt"'r' );
stream_encoding$f'iso-8859-5' );
?>