![]() |
Correct encoding - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Correct encoding (/showthread.php?tid=11844) |
Correct encoding - El Forum - 09-25-2008 [eluser]Dauntless[/eluser] Hi, Actually don't think that this is CI-related, but I'm asking anyway: In a previous site I wrote with CI, there were a lot of (fe) french characters (like é, à, ç, etc) and each time those characters could come up, I printed them like this: Code: htmlentities($item->name, ENT_QUOTES, 'UTF-8') Now, this is a really annoying way; It's a lot of extra typing and easy to forget somewhere. Is there a better way to do this, once and for all ? I know that it also has to do with the way the data is stored in the DB, but when I just try Code: print 'àçé' All help is appreciated! Kind regards, Dauntless Correct encoding - El Forum - 09-25-2008 [eluser]Dan Bowling[/eluser] Change your page's character set. I _think_ this is the one for French: Code: <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> Correct encoding - El Forum - 09-25-2008 [eluser]HdotNET[/eluser] Keep the character set uniform from database through to file and output. So use this: Code: <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> You may also want to send a UTF-8 server header prior to serving the page. In my experience, using UTF-8 _everywhere_ means you have to pay less attention charset's in general. EDIT: thought I was writing in a wiki and screwed the markup. Correct encoding - El Forum - 09-25-2008 [eluser]Yash[/eluser] Try searching the forum on this topic.. There are already huge threads. Correct encoding - El Forum - 09-25-2008 [eluser]Dauntless[/eluser] @HdotNET: I already have that line in my document... What else could go wrong ? I'm using ZEND studio, is there any way it could be saving my documents in the wrong encoding ? //EDIT I changed my workspace encoding to UTF-8 and now everything seems to be working! For other users: In Zend: Window -> preferences -> General -> Workspace -> encoding -> UTF-8 |