Codeigniter and charsets Codeigniter and charsets codeigniter codeigniter

Codeigniter and charsets


1) There is no global solution.

2)

AddDefaultCharset UTF-8

It's needed for Apache response to client with right encoding. Make it.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

not necessarily, but recommended by W3C.

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

it's desirable

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

Encoding for CI connection to database. If encoding of your database is UTF-8 - make it mandatory.

header('Content-Type: text/html; charset=UTF-8');

Do not do this unless necessary. Charset already indicated in HTML code and .htaccess.

Use utf8_unicode_ci or utf8_general_ci for the MySQL database? And why?

For their own language (Russian), I use utf8_general_ci.

In my editor (Notepad++) save files as UTF-8?

Absolutely! All code that Apache will give as UTF8 should be in UTF8.

How about reading RSS feeds, how to handle multiple charsets?

If you have each RSS in each table - you can specify charset for each table and set right encoding with each sql query.Yes, cyrillic symbols, for example, will fails on non-UTF8.


UTF-8 (without BOM) should give you the best results based on your configuration and there's no need to send separate headers since the encoding is already selected in the head part. Utf8_general_ci should do fine for the MySQL database.Perhaps the entries in the database are not valid?