I have script that reads remote file content and writes it to local server. File contains characters: ąčęėįšųūž. After data insertion into local file, UTF-8 encoding is lost. My script code:
<?php
$data = file_get_contents('remote_file_address');
echo $data; //encoding is ok
$file = dirname(__FILE__) . '/../downloads/data.csv';
file_put_contents($file,$data); //invalid encoding in data.csv file
?>
I also followed the instructions depending this post(How to write file in UTF-8 format?), but still no good.
So what is wrong with that? Any ideas?