stream_get_contents not supporting multiple-byte characters?
For example, this is my code:
<?php
$url = 'http://translate.google.com/translate_tts?tl=zh&q=你好';
header('Content-Type: audio/mpeg');
$handle = fopen($url, 'rb');
echo stream_get_contents($handle);
fclose($handle);
?>
At the current time, there is no need to worry about what that means.
Now, I tried running this, and all it does is produce an empty mp3 file.
But when I copy / paste the URL into Google Chrome, it sounds just like it should.
Now, if I change the URL to http://translate.google.com/translate_tts?tl=en&q=hello, it works perfectly. I think that means that there’s no error in my code, but maybe an improvement is needed.
Now, this is the third option that I have tried. I first started off with file_get_contents, then tried cURL, now this. I’m convinced that this can work somehow. Is it because stream_get_contents and other similar PHP functions do not support multiple-byte characters by default, or what?
I also tried url encoding the chinese text, but with no avail.
Any help?














