Encoding problem with MySQL

Discussion in 'MySQL' started by Zhu, Oct 19, 2007.

  1. #1
    I have a problem displaying Chinese encoding on my blog. After researching and getting no answers, I sent an email to my hosting company, Site5.

    They replied :

    I'm not too comfortable dealing with MySQL - this is my first self-hosted blog.

    I don't expect you guys to do the dirty job for me, but could you:

    1) Tell me if the suggestion from Site5 looks smart (I don't want to play with MySQL for nothing !)
    2) Point me to a good and clear MySQL guide for backup/ reinstall (so many advice out there... I need something reliable)
    3) Import the data in UTF-8 encoding ??? I don't get this step...

    I know I sound scare but... yeah, I am :D

    Thanks a lot !
     
    Zhu, Oct 19, 2007 IP
  2. moodswing

    moodswing Peon

    Messages:
    188
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    moodswing, Oct 20, 2007 IP
  3. upl8t

    upl8t Peon

    Messages:
    80
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Couple things, first make sure your table is specifically setup to store UTF8.

    The collation for the table should be something like "utf8_general_ci".

    If the table is stored as utf8, check the data to see if it's storing the right info when you make a post.

    If it is, then you've got a display problem.

    Make sure the post is being returned as UTF8. When using firefox, right click on the page that should have Chinese and click on "View Page Info". You should see an Encoding field at the top that says "UTF-8".

    To make your page return UTF-8 it has to set it in the header using:

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    If this is set and the page is returning UTF-8, then it may be a problem with your php commands to either set or get the utf-8 data.

    I've had quite a few problems in the past doing this, including having to put mysql specifically into utf8 mode, etc.

    But you first want to figure out where the problem is. Storing, Fetching, or Displaying.

    Try putting some static chinese text on the page (html) that is pulling the post. For example in the template.

    IF you can see the chinese, then it's not a problem with the displaying of the chinese (html encoding) but with the setting/fetching itself.
     
    upl8t, Oct 22, 2007 IP
  4. Zhu

    Zhu Well-Known Member

    Messages:
    321
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #4
    Thanks for the post, very informative !

    Alright, so from what I see...

    In MyPhpadmin :

    # MySQL charset: UTF-8 Unicode (utf8)
    # MySQL connection collation: utf8_unicode_ci"

    When I open the wrdp table, they're all set in : latin1_swedish_ci

    Using FF, I checked the page encoding : text/html; charset=UTF-8

    So, diagnostic, doctor(s) ?

    Sorry, I'm still new at that !
     
    Zhu, Oct 22, 2007 IP
  5. Zhu

    Zhu Well-Known Member

    Messages:
    321
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #5
    Update...

    I finally tried the solution I posted first (dropping the WP table and recreating the database). I did import my data specifying the UFT-8 encoding... but once again, I ended up with latin1_swedish_ci tables.

    I don't understand !!! :confused:

    What else can I do to finally show "nice" Chinese posts (instead of my ????? characters...).
     
    Zhu, Oct 22, 2007 IP
  6. upl8t

    upl8t Peon

    Messages:
    80
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    upl8t, Oct 23, 2007 IP
  7. Zhu

    Zhu Well-Known Member

    Messages:
    321
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #7
    Okay, I finally made it !

    Thanks for your help... the problem was the character set and yes, I did have to convert. Whew, took me a while to get that one but my Chinese posts finally look like Chinese and not ?????

    :)
     
    Zhu, Oct 23, 2007 IP