note 85008 deleted from function.file-get-contents by salathe

From: Date: Mon, 21 Sep 2020 14:39:50 +0000
Subject: note 85008 deleted from function.file-get-contents by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-215258@lists.php.net to get a copy of this message
Note Submitter: colnector bla-at_bla colnect.com ---- A UTF-8 issue I've encountered is that of reading a URL with a non-UTF-8 encoding that is later displayed improperly since file_get_contents() related to it as UTF-8. This small function should show you how to address this issue: <?php function file_get_contents_utf8($fn) { $content = file_get_contents($fn); return mb_convert_encoding($content, 'UTF-8', mb_detect_encoding($content, 'UTF-8, ISO-8859-1', true)); } ?>

« previous php.notes (#215258) next »