SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict scoobasteve1982's Avatar
    Join Date
    Apr 2007
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Chinese display in mySQL and PHP

    Hi there,

    Some of you who might read may notice I've posted something similar before. I am working on displaying Simplified Chinese on my site. The only problem is, is that if I take the simplified Chinese and post directly into mySQL via phpMyAdmin the characters when accessed through PHP do not display at all. However, when I post from a web based form with Chinese characters they get convereted in mySQL into something like the following:

    Code:
    & # 21363; & # 23558; & # 21040; & # 26469;
    
    please note above that the & and # and numbers are usually pushed together, but when I do this, your browser will convert them to Chinese.

    Can anyone tell me why this occurs? I want to simply post the Chinese into phpMyAdmin and have it just work. I'm using a UTF-8 collation for my database and a utf8_general_ci collation for the text fields that hold Chinese and other languages. Any help would be GREATLY appreciated. Thanks for your time!

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You form processing script uses htmlentities which converts all applicable characters to html entities.
    Saul

  3. #3
    SitePoint Addict Wildhoney's Avatar
    Join Date
    Apr 2006
    Location
    Nottingham
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You'd be better off converting your data to UTF-8 like so:

    PHP Code:
    szEncoding 'ASCII';
    $szData 'Add odd characters here.';
    $szData = @mb_convert_encoding($szData'UTF-8'$szEncoding); 
    You can detect the encoding in many ways, such as the meta tag in the header of the document, and then default to ASCII if none found. You can also use mb_detect_encoding() to try and detect the charset currently being used.
    TalkPHP.com - The Friendly PHP Community

    Watch Reaper Online - Watch Chuck Online

  4. #4
    SitePoint Addict scoobasteve1982's Avatar
    Join Date
    Apr 2007
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks!


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
  •