Welcome Guest, Not a member yet? Register   Sign In
Character Encoding... Ugh!
#1

[eluser]slowgary[/eluser]
Hi All,

I've been digging through posts on these forums as well as the Goog regarding character encoding, it seems one of those topics that's so scattered it's hard to find an answer to my specific problem.

I've got content that uses the character "è". If I save it to the database using phpMyAdmin, all is okay, and if I save it with a one-off script containing only the db connection plus the query, it's also ok. If, however, I save it using an application built using CodeIgniter (1.7.2), it gets converted to garbled junk ("è").

I've tried a few various things blindly (changing collation on the tables, changing the collation in database.php config file, etc) but nothing corrects it. I don't entirely understand the problem... the database has no issues with the character, the browser has no issues with the character... somewhere in the code Codeigniter seems to be doing some encoding work, but I can't find where that happens either.

Any ideas?

Thanks in advance for reading.
#2

[eluser]CroNiX[/eluser]
Use UTF-8 for your database and also tables (make sure to change in CI database settings as well). Then also put a <meta charset="utf-8"> tag in the head of your document so you tell the browser to use UTF-8.

This won't convert what's already there in the db, but would work for new data. You'd have to manually convert existing data if you have any.
#3

[eluser]slowgary[/eluser]
Thanks CroNiX.

Should utf8_general_ci do the trick?
#4

[eluser]slowgary[/eluser]
Aha! There's more to the story (there always is, isn't there?). In the CodeIgniter based application, the fields had htmlentities() called on them before being displayed to the screen. Turn's out that was the culprit all along.

Thanks again CroNiX!




Theme © iAndrew 2016 - Forum software by © MyBB