I have a text file stored in a server which is encoded in UTF-8 and im trying to load that file from a webpage in another server which is encoded in shift_JIS. I cant get it to work though. This is my original code:
function whatever() {
$open_file = fopen("http://www.myass.com/whatever.txt", 'r');
$whatevers = explode("*", fgets($open_file));
$whatevers_num =count($whatevers)-2;
$i=1;
while($i <= $whatevers_num) {
$details = explode("|", $whatevers[$i++]);
echo <<<EOF
$details[1] - $details[2] - $details[3]
EOF;
}
fclose($open_file);
}
I tried by doing this:
function whatever() {
$open_file = fopen(mb_convert_encoding("http://www.myass.com/whatever.txt", "shift_jis"), 'r');
$whatevers = explode("*", fgets($open_file));
$whatevers_num =count($whatevers)-2;
$i=1;
while($i <= $whatevers_num) {
$details = explode("|", $whatevers[$i++]);
echo <<<EOF
$details[1] - $details[2] - $details[3]
EOF;
}
fclose($open_file);
}
and even this:
function whatever() {
$open_file = fopen("http://www.myass.com/whatever.txt", 'r');
$whatevers = explode("*", fgets($open_file));
$whatevers_num =count($whatevers)-2;
$i=1;
while($i <= $whatevers_num) {
$details = explode("|", $whatevers[$i++]);
echo <<<EOF
$details[1] - $details[2] - $details[3]
EOF;
}
fclose($open_file);
}
ob_start();
whatever();
$get_whatever = ob_get_contents();
ob_end_clean();
$encode = mb_convert_encoding("$get_whatever", "shift_jis");
echo $encode;
but nothing worked, i get only garbled characters. What can i do?
Thank you.