CodeIgniter Forums
CI can't display UTF8 data that equivalent PHP/mysql code has no trouble with - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: CI can't display UTF8 data that equivalent PHP/mysql code has no trouble with (/showthread.php?tid=55786)

Pages: 1 2


CI can't display UTF8 data that equivalent PHP/mysql code has no trouble with - El Forum - 11-09-2012

[eluser]Narf[/eluser]
Btw, a second look points me to another guess - it is quite possible that the data was erroneously encoded while it was inserted (assuming you didn't do that via CodeIgniter).

Another thing that you should take care of is to have the database itself created with default character set utf8 (not just the table).


CI can't display UTF8 data that equivalent PHP/mysql code has no trouble with - El Forum - 11-11-2012

[eluser]Jeffrey McManus[/eluser]
The database is not where the problem lies. If the database were the problem, then I would not be able to query and display the database correctly using PHP/mysql. (Right?)

That said, SHOW CREATE DATABASE confirms that the database was created with a default character set of UTF8.


CI can't display UTF8 data that equivalent PHP/mysql code has no trouble with - El Forum - 11-11-2012

[eluser]Jeffrey McManus[/eluser]
I just thought of one more thing to try that pretty much confirms my assertion that this is an issue with CodeIgniter 2.1.x rather than a configuration issue or a problem with the data.

I grabbed a copy of CodeIgniter 3.0-dev from Github, configured it to work against the same database, on one of the same dev machines were I saw the problem last week.

Display of the data works correctly in this scenario. So from this, it's clear that between 2.1.2 and 3.0-dev, something changed with the way that unicode data is being handled. PHP/mysql does it right, CI 3.0-dev does it right, but CI 2.1 does not do it right.


CI can't display UTF8 data that equivalent PHP/mysql code has no trouble with - El Forum - 11-11-2012

[eluser]Jeffrey McManus[/eluser]
And by trying the same code in a fresh install of CI 2.1.3, I am able to confirm definitively that the unicode problem is a bug in CI 2.1.2.

Thanks for your suggestions for resolving this, Narf.


CI can't display UTF8 data that equivalent PHP/mysql code has no trouble with - El Forum - 11-12-2012

[eluser]Narf[/eluser]
You're welcome.

However, nothing has changed between 2.1.2 and 2.1.3 that affects this.

EDIT: Links somehow get broken, can't post the compare diff link.