SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Wizard Busch's Avatar
    Join Date
    Jan 2004
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Storing Unicode in Database

    I am working with mostly English but a bit of Korean text. All text is INSERTed into my MySQL database. How can I ensure that the Korean text is stored in the database as Unicode and not html entities?

    MySQL: 4.0.22-standard
    PHP: 4.3.8

  2. #2
    SitePoint Zealot shenkong's Avatar
    Join Date
    Sep 2004
    Location
    China
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    make sure your submit page's coding is UTF-8, u can use
    header("content-type: text/html; charset=utf-8");
    for the submit page , then the text which users type is utf-8 coding

  3. #3
    SitePoint Wizard Sillysoft's Avatar
    Join Date
    May 2002
    Location
    United States :)
    Posts
    1,691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    Boston
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    I always just use a conversion script...

    How to use it....

    include_once ( 'convert.php' );

    when you place a string in the database use....

    $str = convert ( $str, 2 );

    when you get stuff out of the database and want to insert that text in a text document use...

    $str = convert ( $str, 1 );

    If your just displaying it in a HTML document, you will not have to use the function convert() when taking it out of the database!


    J!
    Attached Files Attached Files

  5. #5
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Next to the Biz Hub
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nice DL. I may use this too. Thanks.

  6. #6
    SitePoint Wizard Busch's Avatar
    Join Date
    Jan 2004
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jbr
    Hi

    I always just use a conversion script...

    How to use it....

    include_once ( 'convert.php' );

    when you place a string in the database use....

    $str = convert ( $str, 2 );

    when you get stuff out of the database and want to insert that text in a text document use...

    $str = convert ( $str, 1 );

    If your just displaying it in a HTML document, you will not have to use the function convert() when taking it out of the database!


    J!
    I am very anxious for this script to be approved

  7. #7
    SitePoint Wizard Busch's Avatar
    Join Date
    Jan 2004
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK! Thanks for everyone's help. After a few modifications of these ideas I got it to work.

    But I have one more question, Is the unicode supposed to look like this in my database?
    광주 지ì—

    I was kind of hoping for something, well, ummm, prettier... Does that look normal?

  8. #8
    SitePoint Wizard Busch's Avatar
    Join Date
    Jan 2004
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry .

    Actually I thought my problem was solved until IE!!!

    I ran the same script that worked on Firefox(Mac) on IE(Mac) and it totally rendered the text unreadable! It works fine in Safari as well

    What can I do to make it work in IE?

  9. #9
    SitePoint Wizard Busch's Avatar
    Join Date
    Jan 2004
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Busch
    But I have one more question, Is the unicode supposed to look like this in my database?
    광주 지ì—

    I was kind of hoping for something, well, ummm, prettier... Does that look normal?
    Anyone?


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
  •