NYCPHP Meetup

NYPHP.org

[nycphp-talk] UTF-8, databases and best practices

Eugenio Tacchini eugenio.tacchini at gmail.com
Sat May 19 09:11:59 EDT 2012


Hi all,
I need to distribute an application that potentially can be used with
many different DBMSs (such as MySQL, PostgreSQL, SQLite, Microsoft SQL
Server). The charset used in the databases can be ANY.

I would like to always output UTF-8 text when possible and my
questions are about the current best practices to handle this kind of
application with PHP.

1) As far as I know, PHP still doesn't support natively utf-8 so to
avoid problems with string functions, I still have to use mbstring
fucntions, am I right? What does PHP 5.4 change about that?

2) How to handle the fact that the data I receive from the database
can be stored using any possible charset? Do I need iconv functions
and convert everything in utf-8? And then convert it back in the
original charset when I have to write to the DB?

Thanks!

Eugenio



More information about the talk mailing list