glennv
glennv

Reputation: 713

CodeIgniter make default charset utf-8 instead of iso-8859-1

My codeIgniter application serves all html pages with a header of Content type: text/html; charset=iso-8859-1. I would like it to serve utf-8 by default. I checked the config file and the database config file.

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

It just keeps encoding iso-8859-1..

Upvotes: 0

Views: 1583

Answers (2)

Max
Max

Reputation: 674

If you are using Apache, add this in .htaccess

AddDefaultCharset UTF-8

Upvotes: 1

Shauna
Shauna

Reputation: 9596

Make sure your HTML templates aren't setting a different charset. Check whatever templates have the opening <html> and/or <head> tags.

Edit Since your templates are encoded properly, it will probably be worthwhile to do a quick "find in files" search for iso-8859-1 and see where it's getting overridden. If it's anywhere in the core CodeIgniter instance, and you're using the most recent version (and haven't edited the core), then it might be a bug, and you'll need to report it to the CodeIgniter people.

Keep in mind, though, that it's not necessarily a bug, but a different setting overriding that one. Make sure you look at the context of any instances you find it, before you jump to the bug report form.

Upvotes: 0

Related Questions