Search code examples
mysqlcodeigniterencodingcodeigniter-form-helper

Difference in utf8 (greek) characters output in codeigniter, standard html vs form helper


This:

<td><?php echo form_input('post_title',set_value('post_title',$post->post_title)); ?></td>

Will present greek characters (or any other than latin character), as &#xxx on the page.

This:

<p>Title: <input name="post_title" type="text" value="<?php echo $post->post_title ?>"/></p>

Will display it correctly.

Web page

My MySQL type is MyISAM and utf8_latin_ci collation.

Trying browse from phpMyAdmin also gives me greek in &#xxx...

phpMyAdmin

Where is the mistake?

P.S From codeigniter manual regarding the form helper methods

and will always add the attribute accept-charset based on the charset value in your config file.

My config file is set to

$config['charset'] = 'UTF-8';

UPDATE: My page headers:

GET /posts/editpost/23 HTTP/1.1
Host: my.xxx.com
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.152 Safari/537.22
Referer: http://my.xxx.com/posts
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

Solution

  • This is a general issue with the characters set. Please keep the character set encoding same at every place like in HTML files, CI config file and most important at the database. While creating a database, select UTF-8 or any other other which suits to your language (for most languages UTF-8 works). Or you can change it for individual tables also. Please make these changes and you will get the correct one for greek language. Thank you