CodeIgniter Forums
my problems are html encoding? (I use utf8) - 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: my problems are html encoding? (I use utf8) (/showthread.php?tid=6882)



my problems are html encoding? (I use utf8) - El Forum - 03-15-2008

[eluser]sunyoupk[/eluser]
Hi~ I'm working korean web page. I have problems....
my view page name is "blog_post"(this page is write entrie page)

(Korean is two byte unicode so I always using utf-8)
current working page charset is utf-8 but language is crashed in browser(?!)
but the MySQL database that is a very good character to come calling
(database field type = varchar, characterset = utf8)

my code...
Code:
...
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
....
....
<select name="categories" size="1">
    <option value="">카테고리를 선택해주세요</option>(<-crashed sector)
    &lt;?php foreach($query->result() as $row):?&gt;
    <option value="&lt;?=$row->seq?&gt;">&lt;?=$row->cat_name?&gt;</option>(<-Korean word)
    &lt;?php endforeach;?&gt;
</select>

Why are directly expressed in the article is broken HTML pages, MySQL database or taken from the show?


my problems are html encoding? (I use utf8) - El Forum - 03-16-2008

[eluser]webthink[/eluser]
Assuming that MySQL db and tables are set to utf8 (check that), I'm guessing that the problem is that SET NAMES = ‘UTF-8’ is not being issued before interacting with the db.

In Codeigniter 1.6.1, this is automatic, if you set in config:

Code:
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

Otherwise, I think you'll need to manually

Code:
$this->db->query("SET NAMES 'utf8'");

Before reading or writing.