Do you have a question? Post it now! No Registration Necessary. Now with pictures!
February 22, 2007, 10:02 pm
rate this thread
I'm running php5 and mysql5, both configured for utf8... When I save
data into a table, and look at the table with e.g. phpmyadmin, the
has weird characters like: Ã¨ and Ã© in it.Actually this isn't a
big problem: when I print the data in my browser, the accents look
I read that when you execute a query "SET NAMES utf8", the weird chars
would disappear in the db, ...and still everything works fine.
So I tried to decode the utf8 data in my tables with using
utf8_decode... But it seems like it doesn't decode everything.
For example this doesn't work :echo utf8_decode('ProblÃ¨me Ã la
sauvegarde des donnÃ©es.');
You will notice the Ã isn't converted into an à.
So I have 2 questions :
- should i use the SET NAMES query, or is it normal when you have
characters in your table
- how can I convert the Ã into an à
Thanks in advance!
I have burned my fingers a lot with encodings, lately. The problem is
that texts do have encodings, while strings do not. And off course, that
texts are stored as strings.
what you are seeing is utf-8, but shown as if it was latin-1 (or a
derivative). The reverse shows question marks, as most special
characters in latin-1 are not well formed utf-8.
I installed phpMyAdmin as well, because the site and the browser are now
working together just fine (IE and Firefox, at least), So any text gets
entered in utf-8 in the database and rendered the same as it was
entered. My hope was that phpMyAdmin would enable me to enter strings
directly into the database, as it is running inside a browser also. Bad
luck. Both phpMyAdmin and my regular database frontend show utf-8 as if
it is latin-1.
There is a lot that can go wrong:
- Your OS has an encoding
- The frontend program may have an encoding
- The database connection has an encoding
- The field has an encoding
There may be conversions at any point, but mostly texts are not
converted and I do not understand why you can give an encoding if it is
never used anyway.
Alas, there is no "unicode escape" either in MySQL (like "/Uxxxx" in
some languages). So it is impossible to store a query in a file, upload
it to another OS and have the encoding automagically set right. Some
encoding solutions are really laughable. Do you think that "SET NAMES
utf16le" will ever be executed? Only if it is a lie and NOT issued in
such an illegible encoding.
I am sorry that this is not very helpful, but I think I just need a
shoulder to cry on.
- » Are there any good solutions for checking the validity of IP address?
- — Previous thread in » PHP Scripting Forum