Problem with swedish characters in database |
[eluser]Tomas Sundvall[/eluser]
Hello! I have a pretty strange problem with swedish characters on my website. All my files are coded in utf8, and it works good. My database tables use latin1, but when I output data it still works good. The problem is when I submit data to the database, and then tries to output it, then all the swedish characters are messed up. I have tried to use utf8 in the database instead of latin1, but then the problem just get worse and all the data I output gets messed up. In the config file I use following settings: $db['default']['char_set'] = "utf8"; $db['default']['dbcollat'] = "utf8_general_ci"; And this is how I tried to change the charset of the database tables: ) ENGINE=MyISAM DEFAULT CHARACTER SET = utf8 COLLATE = utf8_general_ci AUTO_INCREMENT=1; I think it's strange that it works when I use latin1 in the database, but even more strange that the problem get worse when I change it to latin1. Does anyone have a clue to what the problem might be? I'm very thankfull for all help! /Tomas
[eluser]tomcode[/eluser]
Don't have an answer, but : 1. do You use UTF-8 in the form (accept-charset) ? 2 if You change the charsets with data in the tables, the results become unpredictable
[eluser]Tomas Sundvall[/eluser]
1. Yes I do. That's one of the first things I checked. 2. I haven't changed any tables contained with data. I changed the .sql file that contained both the data and the database structure, and then I just recreated the database.
[eluser]tomcode[/eluser]
I'd first try with an empty, fresh installed database to see whether it works. Only then I'd deal with the existing data.
[eluser]davidbehler[/eluser]
Maybe this thread helps: http://ellislab.com/forums/viewthread/124193/ I'm pretty sure it has something to do with the charset you are using. Have you looked at your data in phpmyadmin? Does it look right there?
[eluser]Phil Sturgeon[/eluser]
Remember, you need to set UTF-8 on the database connection, the table, the field, the PHP header AND in the HTML. Plenty of places for it to go wrong.
[eluser]davidbehler[/eluser]
And be sure your Apache server does not set the default char set back to "ISO-8859-1". You can prevent that by sending this: Code: header('Content-type: text/html; charset=utf-8');
[eluser]Tomas Sundvall[/eluser]
Hello! Thanks alot for all help, I found the problem! Since I was using the data for a pdf, I didn't use my standard template where I specidfied that the page used utf8. So what I had to do was to specify that in the begining of the pdf. /Tomas |
Welcome Guest, Not a member yet? Register Sign In |