Welcome Guest, Not a member yet? Register   Sign In
DB charset in CI 1.6.0
#11

[eluser]dik_[/eluser]
The code in my first post is an extract from the DB.php file, which I have modified to include the penultimate line shown, in order for UTF8 to work for me.

I don't manually initialize the DB myself, I have it done automatically in application/config/autoload.php:

Code:
$autoload['libraries'] = array('database', ...);

Did some more testing, and removed the db from the autoloading array, manually loading it in my controller's constructor, as you suggested. Still, I get garbage characters instead of readable text, and still the same queries are ran (nothing related to setting the char set that is)...
#12

[eluser]Référencement Google[/eluser]
The datas in the DB was previously inside? Was the encoding of you datas entered as UTF-8?
Also, can you make a test with a clean new install of CI + another DB ?
#13

[eluser]Firestorm ZERO[/eluser]
I have the same problem. I have the content-type metatag in my pages and the character encoding in Firefox is set for Unicode (UTF-8). I was getting messed up characters. The database is mySQL and the table is set for 'utf-8' charset and using 'utf8_general_ci' collation. The DB config file is also set the same.

I did what dik_ has in his DB.php and added "$DB->query("SET NAMES 'utf8'");" at the bottom and now the characters are displaying ok.
#14

[eluser]Derek Jones[/eluser]
What version are you running, and does this apply, Firestorm ZERO?
#15

[eluser]Firestorm ZERO[/eluser]
Using CI v1.6.0 and the database is loaded in autoload.php.
#16

[eluser]dik_[/eluser]
Has anyone ever tried this with non-english (ascii) characters? Anyone except Firestorm ZERO of course...
#17

[eluser]Référencement Google[/eluser]
I am using french with characters like é à è ü etc... and that is working perfectly with CI 1.6 theses characters aren't encoded with é or things like that, they are stored directly as is in the DB, but of course all the production environment is set with UTF-8 encoding, this mean the DB, the tables and table fields, the PHP headers, the HTML headers, AND the pages in PHP are also created in UTF-8 (I mean I am using the option of my IDE to create files as UTF-8).
#18

[eluser]dik_[/eluser]
Yes, i've done all that.

The fact that this one line in Db config makes all the difference reinforces this. I mean, at the very least, setting names to UTF8 manually, definitely makes the mysql UTF8, right? So, if I don't include that line, and my characters look like garbage, then definitely CI is missing something, right? Big Grin
#19

[eluser]Référencement Google[/eluser]
Dik_, You didn't answer one of my previous posts:
Quote:The datas in the DB was previously inside? Was the encoding of you datas entered as UTF-8?
Also, can you make a test with a clean new install of CI + another DB ?

Also, with what are you inserting your datas? PhpMyAdmin? Another tool? A form in your pages? Copy and past from some software on your computer?
#20

[eluser]dik_[/eluser]
everything was utf8 from before, via html forms. all files are saved as utf8, all collations/charsets, everything is utf8

I didn't try a clean install, as I'm sure it won't help in anything... At the end of the day, I don't mind having that one extra line in DB.php, as long as my job is done...

I was just reporting what might be a bug... and since at least another user got exactly the same situation as me, it may well be one Smile




Theme © iAndrew 2016 - Forum software by © MyBB