1

I'm from Hungary which makes things complicated if talking about character encoding. When I code websites I cannot avoid storing simple data in MySQL which normally would not require an admin surface to handle. I mean I would not make an admin for recording menu names in a table. But I have to. Since it's impossible (or I haven't found a solution yet) to record UTF8 attributes in phpMyadmin. My input stays ISO-8859-2 encoded in the UTF8 field as I send it via phpMyadmin. If I send data to the database using an UTF8 webpage, UTF8 form, everything UTF, I have absolutely no problem.

So my point is that it's circumstantial and time-consuming to make an admin surface or something like that every time I want to insert some UTF8 to an UTF8 encoded database. phpmyadmin is unusable for me. But I don't feel like programming another phpmyadmin on my own. It would make no sense. There must be a solution. Can you help?

Actual UTF8 attributes show off the right way. The line marked with blue line has been recorded with phpmyadmin and is not stored as UTF8.

(Actual UTF8 attributes show off the right way. The line marked with blue line has been recorded with phpmyadmin and is not stored as UTF8.)

Rápli András
  • 3,869
  • 1
  • 35
  • 55
  • phpMyAdmin works perfectly fine with UTF-8. You may simply have misconfigured it. How do you figure that your "input stays ISO-8859 encoded"? This makes little sense. – deceze Jul 25 '13 at 12:29
  • It's a returning problem for me on every database I've ever used. Let it be in USA, Europe, absolutely unrelated servers and configurations. I get the same problem everywhere. If I input something via phpmyadmin, it's LATIN-2 only. Even if the field is UTF8. – Rápli András Jul 25 '13 at 12:31
  • How do you figure the input is "Latin2"? What leads you to this conclusion? Details, man, details! :) – deceze Jul 25 '13 at 12:34
  • Look at the picture I've just added. – Rápli András Jul 25 '13 at 12:36
  • In the screenshot you show we see that **characters** are stored nicely as they should be (blue arrow). It doesn't say anything about what **encoding** they're in. If you think that the garbage above is "actual UTF-8" then you need to read [What Every Programmer Absolutely, Positively Needs To Know About Encodings And Character Sets To Work With Text](http://kunststube.net/encoding/) and my guess below is correct. – deceze Jul 25 '13 at 12:37

3 Answers3

4

I'll just take a very wild stab into the dark:

phpMyAdmin actually gets it right. The one that isn't working is your custom interface, because it's not setting the connection encoding correctly. So all the data you insert via it is messed up in the database but happens to have a clean roundtrip in your application. phpMyAdmin inserts actual UTF-8 data, which messes up when retrieved via your wrong connection.

See UTF-8 all the way through and Handling Unicode Front To Back In A Web App.

Community
  • 1
  • 1
deceze
  • 510,633
  • 85
  • 743
  • 889
  • I know how to use UTF8 with php, please link a resource about the setup in phpmyadmin. – Rápli András Jul 25 '13 at 12:40
  • Well, just to 100% rule out any possibility about *your* PHP script being wrong: what have you set the SQL connection encoding to and how? – deceze Jul 25 '13 at 12:43
  • When I record data via PHP, I use UTF-8 headers, a form with UTF8 encoding, and the .php file itself is UTF8 without BOM. – Rápli András Jul 25 '13 at 12:44
  • 2
    **But you're not setting the SQL connection encoding!** Go read the abovelinked articles. – deceze Jul 25 '13 at 12:46
2

For those who might find this article in the future with the same problem, I've set the connection encoding right after setting up the connection using this query:

SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'

Rápli András
  • 3,869
  • 1
  • 35
  • 55
0

I had exactly the same problem as you. After a while, I figure out the solution, using a utf8-to-html online converter at Convert to HTML . Just type your Unicode text and copy the result, paste into your PHPMyadmin.

Duc Tran
  • 6,016
  • 4
  • 34
  • 42