I am trying this code
$json = file_get_contents(\"http://www.google.com/alerts/preview?q=test&t=7&f=1&l=0&e\");
print_r(json_decode(utf8_enc
The iconv function is pretty worthless unless you can guarantee the input is valid. Use mb_convert_encoding instead.
mb_convert_encoding($value, "UTF-8", "auto");
You can get more explicit than "auto", and even specify a comma-separated list of expected input encodings.
Most importantly, invalid characters will be handled without causing the entire string to be discarded (unlike iconv).