NYCPHP Meetup

NYPHP.org

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

Eugenio Tacchini eugenio.tacchini at gmail.com
Thu May 24 04:07:04 EDT 2012


>> 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?
>
> I'd be interested to hear other's thoughts, but the general consensus these
> days is "convert all to UTF-8".  Is there an application-requirement-reason
> that you'd need to convert data to a different charset at different times?
>
> In general:
>
> 1. Raw data (any charset/encoding)
> 2. Detect and convert to UTF 8, clean-up, etc.
> 3. Store in database/etc
> 4. Read/display in UTF 8

Hi all and thanks for the interesting answers!
The problem 2) is still the one I'm not completely sure about; in
almost all your answers you suppose I can decide how to setup the
database but it is not the case. This application has to work with any
database settings, I can't force the users to ALTER the database
charset and make it UTF-8.
So should I have to read and convert on the fly (using PHP ICONV) to
UTF-8 from the database and then convert it back again before writing?
I can't just assume to work with UTF-8, right?

Thanks again.

Eugenio

--------------------
DaDaBIK  - Database Interfaces Kreator
http://www.dadabik.org



More information about the talk mailing list