I am trying to use the Microsoft Bing API.
$data = file_get_contents(\"http://api.microsofttranslator.com/V2/Ajax.svc/Speak?appId=APPID&text={$text}&
You should not simply discard the BOM unless you're 100% sure that the stream will: (a) always be UTF-8, and (b) always have a UTF-8 BOM.
The reasons:
I think a more appropriate way to handle this would be something like:
/* Detect the encoding, then convert from detected encoding to ASCII */
$enc = mb_detect_encoding($data);
$data = mb_convert_encoding($data, "ASCII", $enc);