SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Addict FizixRichard's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    372
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Post Korean Text in DB

    Hi,

    I'm currently working on a website which needs to store English and Korean text in a DB field.

    The problem is, the Korean typeface is not being stored correctly, it's being totally garbolled.

    I believe it has something to do with the DB fields properties, the entry form is a normal text entry field that inserts the data into a mysql DB.

    For reference:

    This: 회원가입

    is being turned into this: ȸ

    Does anyone know what is up with this?
    FIZIX - Full Service Digital Agency - Engaging websites, apps and games.
    Follow us @FIZIXAgency

  2. #2
    SitePoint Evangelist DMacedo's Avatar
    Join Date
    May 2004
    Location
    Braga, Portugal
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem is in the table's default character set, you should use UTF8 to store korean (or any other multi-byte char language alike)
    ~ Daniel Macedo

  3. #3
    SitePoint Addict FizixRichard's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    372
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yes, the DB field is UTF8, but it is still garbolled.

    I'll elaborate a little.

    I have a textarea in a form, where the user can entertext. This text is then stored in a MySQL DB (mediumtext). This can then be displayed on the site (dynamic content).

    This fields 'collation' in PHPMyAdmin is set to utf8_unicode_ci (also set it as utf8_general_ci and utf8_bin and it won't work).

    I too was under the impression that UTF8 was the character set we needed to use, so this is really confusing me and taking up way too much of my time on this project (as it's an important feature).
    FIZIX - Full Service Digital Agency - Engaging websites, apps and games.
    Follow us @FIZIXAgency

  4. #4
    SitePoint Evangelist DMacedo's Avatar
    Join Date
    May 2004
    Location
    Braga, Portugal
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried inserting the text in phpMyAdmin? Does that work?
    I am sure if you have the right character set and collation it has to work properly.

    If that doesn't work the issue can be in your connection to MySQL not using utf8 or something in those lines

    I'd have to check the PHP (?) handling of the string and debug that myself to properly understand what's wrong.
    ~ Daniel Macedo

  5. #5
    SitePoint Addict FizixRichard's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    372
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hmm...

    OK, entering directly into PHPMyAdmin works, it's stored correctly in the DB however it is displayed on the site as '???? ?? ???' like that.

    So something somewhere isn't right, I'm really not sure if its my code (can it be?) or a setup issue with the server?
    FIZIX - Full Service Digital Agency - Engaging websites, apps and games.
    Follow us @FIZIXAgency

  6. #6
    SitePoint Evangelist DMacedo's Avatar
    Join Date
    May 2004
    Location
    Braga, Portugal
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The only thing I can imagine is setting
    Code:
    SET character_set_client = utf8;
    SET character_set_connection = utf8;
    SET character_set_results = utf8;
    Upon your database connection and see if that solves the problem.
    ~ Daniel Macedo

  7. #7
    SitePoint Addict FizixRichard's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    372
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    How do I implement this, add that to the top of the PHP script as is?
    FIZIX - Full Service Digital Agency - Engaging websites, apps and games.
    Follow us @FIZIXAgency

  8. #8
    SitePoint Evangelist DMacedo's Avatar
    Join Date
    May 2004
    Location
    Braga, Portugal
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, try this out.

    Right after your mysql_connect() insert:
    PHP Code:
     mysql_query('SET character_set_client = utf8');
     
    mysql_query('SET character_set_connection = utf8');
     
    mysql_query('SET character_set_results = utf8'); 
    Let's see if that makes a difference
    ~ Daniel Macedo

  9. #9
    SitePoint Addict FizixRichard's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    372
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    It's made a difference, it's now even more garbolled than it was before, lol.

    Register and 회원가입

    Instead of ȸ

    So it is more messed up than before, I've never had the liberty to work with a company in the far east before, so this is rather new to me.

    As a side note, I've tried the following character types in the DB field (and also tried changing the utf8 type in that code sample to reflect).

    utf8_unicode_ci
    utf8_bin
    utf8_general_ci

    The rest of the utf8's in phpmyadmin are latin, roman etc. so I don't think they are appropriate.

    Leaving the setting in your code sample gives a garbolled output, anything else gives a string of ???? ??? ???
    FIZIX - Full Service Digital Agency - Engaging websites, apps and games.
    Follow us @FIZIXAgency

  10. #10
    SitePoint Evangelist DMacedo's Avatar
    Join Date
    May 2004
    Location
    Braga, Portugal
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool

    I think you may be missing something as you're probably using charset ISO-8859-1 on your web page instead of UTF8

    Try that and let me know

    Edit:

    Last edited by DMacedo; Jan 17, 2006 at 13:07.
    ~ Daniel Macedo

  11. #11
    SitePoint Addict FizixRichard's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    372
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    No luck there either, this has me totally baffled.

    Thanks for all your help though
    FIZIX - Full Service Digital Agency - Engaging websites, apps and games.
    Follow us @FIZIXAgency

  12. #12
    SitePoint Evangelist DMacedo's Avatar
    Join Date
    May 2004
    Location
    Braga, Portugal
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Then only checking it I can see what's wrong.
    ~ Daniel Macedo

  13. #13
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    make sure you have the correct character set specified in the header of your HTML document. as a test, you can try changing the character set in the view menu of your browser.

  14. #14
    SitePoint Addict FizixRichard's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    372
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Smile

    Thats a very good point and fixed

    Thankyou to both of you
    FIZIX - Full Service Digital Agency - Engaging websites, apps and games.
    Follow us @FIZIXAgency

  15. #15
    SitePoint Evangelist DMacedo's Avatar
    Join Date
    May 2004
    Location
    Braga, Portugal
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy

    Quote Originally Posted by DMacedo
    you're probably using charset ISO-8859-1 on your web page instead of UTF8
    Quote Originally Posted by RGSerge
    No luck there either
    You pointed it wasn't that
    ~ Daniel Macedo

  16. #16
    SitePoint Addict FizixRichard's Avatar
    Join Date
    May 2003
    Location
    UK
    Posts
    372
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    No, it didnt work set at UTF8, it did however work as euc-kr
    FIZIX - Full Service Digital Agency - Engaging websites, apps and games.
    Follow us @FIZIXAgency


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •