note 85008 added to function.file-get-contents

From: Date: Sun, 10 Aug 2008 09:34:33 +0000
Subject: note 85008 added to function.file-get-contents
Groups: php.notes 
Request: Send a blank email to php-notes+get-143344@lists.php.net to get a copy of this message
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: 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)); } ---- Server IP: 212.199.163.191 Probable Submitter: 89.1.173.27 ---- Manual Page -- http://www.php.net/manual/en/function.file-get-contents.php Edit -- https://master.php.net/note/edit/85008 Del: integrated -- https://master.php.net/note/delete/85008/integrated Del: useless -- https://master.php.net/note/delete/85008/useless Del: bad code -- https://master.php.net/note/delete/85008/bad+code Del: spam -- https://master.php.net/note/delete/85008/spam Del: non-english -- https://master.php.net/note/delete/85008/non-english Del: in docs -- https://master.php.net/note/delete/85008/in+docs Del: other reasons-- https://master.php.net/note/delete/85008 Reject -- https://master.php.net/note/reject/85008 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#143344) next »