![]() |
Character encoding changes suddenly - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Character encoding changes suddenly (/showthread.php?tid=35323) |
Character encoding changes suddenly - El Forum - 10-26-2010 [eluser]Swedie[/eluser] New to CI and started making a method that uses views to display headers and footers from another website of mine. I've encountered a problem, maybe not specifically a CI issue, but an issue nevertheless that I must solve. The problem being that if I include the header and footer, the swedish characters are turned into symbols: * ��� * ��� * �#%�$? If I leave out the header and footer, the swedish characters show up correctly. Thus the file_get_content or CI causes something to change. Why and how do I do this right? Here is all my code! Controller Code: <?php The view file Code: <?=$header;?> Character encoding changes suddenly - El Forum - 10-27-2010 [eluser]Dennis Rasmussen[/eluser] file_get_contents() will cause your site to use the encoding used on the website you are fetching data from (if that website has meta data), so you probably need to convert your fetched data/file to use utf-8 as well. Code: $page = file_get_contents($this->website_url); If that doesn't work, then I don't know ![]() Character encoding changes suddenly - El Forum - 10-27-2010 [eluser]Swedie[/eluser] That didn't work. But changing the meta tag to ISO-8859-1 on the other side, plus doing a utf8_encode on $page made it appear correctly. Not sure though that this is the best of ways. I rather not have to change it like this. Character encoding changes suddenly - El Forum - 10-27-2010 [eluser]Swedie[/eluser] Noticed I had changed the project's character encoding. This caused all files to be ISO-5589-1 making a conflict with all other pages I have that are UTF-8. Atleast I found the cause. I post this for future reference to everyone else that might stumble across the same dilemma. |