I'm having trouble getting my pages to display certain characters from the database correctly.

Discussion in 'HTML & Website Design' started by SZ87, Feb 12, 2014.

  1. #1
    Everything seems to be fine up until the page displays the data from my database.

    Examples:

    1080� (should be 1080°)
    ?kami (should be Ōkami)
    Pok�mon (should be Pokémon)

    I've quadruple-verified that:
    • The pages are tagged for UTF-8 encoding (tried ISO-8859-1 as well, no change)
    • The pages are hardcoded as UTF-8 (converted from ANSI, which made no difference at all)
    • The database tables are UTF-8 with utf8_general_ci collation
    Yet my pages still refuse to display these characters.

    These problematic characters are displayed correctly inside the database itself.
    Let me know if you need code, full documents, or screencaps. Thank you kindly for your help!
     
    SZ87, Feb 12, 2014 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #2
    This might seem silly, but what font are you using? Try switching to arial... not all fonts have all characters or display them properly... PARTICULARLY webfonts.

    Also, are you sure they're encoded properly in the database? If they were sourced from a different encoding they could be screwed up in the database.
     
    deathshadow, Feb 12, 2014 IP
  3. SZ87

    SZ87 Greenhorn

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    13
    #3
    Hi, deathshadow.

    I'm afraid the problem still persists. You got me excited for a minute there because I realized that I had set my font to something other than the widely-used fonts. But changing the font didn't fix it.

    As far as the database goes, here's what a table looks like:
    http://i.imgur.com/qrQUJl8.png

    Notice entries 7 and 14. So I'm not exactly sure what's going on. I've done everything I can think of except starting from scratch (oh please god no.) Although I do still have it all saved in CSV files, so I wouldn't need to enter every single entry.

    If you don't mind me asking, what is the proper way to ensure everything is done correctly?

    To give you an idea, here's what I did:

    1. Create each table in Excel
    2. Export as CSV using UTF-8 encoding under "Web Options" settings
    3. Open with Notepad++ and verified that the CSV file was UTF-8
    4. Import into phpMyAdmin as UTF-8
    5. Convert each table to utf8_general_ci and MyISAM engine (the engine my hosting service requires)
    6. Import into database with UTF-8 set

    I honestly don't know where I went wrong.
     
    SZ87, Feb 12, 2014 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #4
    When you say "tagged for utf-8" on the pages -- do you mean as the meta, or using "header"?

    Are you sure you're doing (assuming php):
    header('Content-Type: text/html; charset=UTF-8');
    Code (markup):
    Somewhere in there? Remember, over the web a lot of browsers ignore the meta, and the meta is always trumped by the header.

    Are you doing any processing on the strings before output? Could we see the query you're using to pull them and the code used to echo them out?
     
    deathshadow, Feb 12, 2014 IP