Welcome Guest, Not a member yet? Register   Sign In
Displaying UTF-8 strings
#8

[eluser]WanWizard[/eluser]
The issue here is that your database (and/or tables) are setup to use latin1. This doesn't say anything about the data in the records, as far as MySQL is concerned that's just a row of bytes.

The data in the records however isn't latin1, it's utf8. This is no problem as long as you connect to the database using the same character set as defined for that database. In that case MySQL knows that no translation is needed, so it sends you the data back as-is, which, as it is utf8, works fine.

Now you connect to the database using CI. CI expects the database to use a utf8 characterset, and configures it as such (in database.php). Now you're telling MySQL that the client connecting uses a different characterset than used to store the data, and it starts converting between the charactersets. Which is the cause of your problem, as converting utf8 text using latin1-to-utf8 conversion rules creates a mess. You get the same from the commandline if you force the connection to be anything else than the database default.

Two possible solutions:
- have CI connect to the database using the characterset the database was setup with, and live with the fact that certain features don't work as expected (for example everything related to collating sequence).
- dump the database, create a new database in utf8, and load the data again. There are several articles on the internet on how to do this.


Messages In This Thread
Displaying UTF-8 strings - by El Forum - 08-24-2010, 07:21 PM
Displaying UTF-8 strings - by El Forum - 08-24-2010, 11:33 PM
Displaying UTF-8 strings - by El Forum - 08-25-2010, 01:58 AM
Displaying UTF-8 strings - by El Forum - 08-25-2010, 02:04 AM
Displaying UTF-8 strings - by El Forum - 08-25-2010, 06:31 AM
Displaying UTF-8 strings - by El Forum - 08-25-2010, 07:26 AM
Displaying UTF-8 strings - by El Forum - 08-25-2010, 07:27 AM
Displaying UTF-8 strings - by El Forum - 08-25-2010, 12:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB