SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Strange characters not being converted

    Look at http://otakuhelpers.com/#news_2 under "entertainment news". I have a problem with certain characters showing up like:


    do you know how to convert this to the proper character? I tried iconv, but it does not seem to do the trick.

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,319
    Mentioned
    462 Post(s)
    Tagged
    8 Thread(s)
    Hi Nination. Welcome to the forums.

    Even though your page specifies the UTF-8 charset, the server is sending the pages as ISO-8859-1. That setting overrides anything on the page. So it would be worth changing your server setup to serve the pages as UTF-8.

  3. #3
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see, thanks for the reply. I'm on shared hosting however. Is there a php function or .htaccess string to modify this? I have no idea why it would be doing that.

    If you could, please list both, but I would prefer an ,htaccess modification as I have the same problem on my vbulletin forums.

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,319
    Mentioned
    462 Post(s)
    Tagged
    8 Thread(s)
    This is not my area, but I'll suggest what I've learned in the past about this.

    Via .htaccess

    You could ass this to your htaccess file (reference):

    Code:
    AddDefaultCharset utf-8
    or perhaps this (source):

    Code:
    <FilesMatch "\.(htm|html|css|js|php)$">
       AddDefaultCharset UTF-8
       DefaultLanguage en-US
    </FilesMatch>
    Via PHP

    You can place this at the top of your pages (reference):

    Code:
    <?php
    header('Content-Type: text/html; charset=utf-8');
    ?>
    Hope that helps.

  5. #5
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In .htaccess I added:
    Code:
    <FilesMatch "\.(htm|html|css|js|php)$">
       AddDefaultCharset UTF-8
       DefaultLanguage en-US
    </FilesMatch>
    In php I added:
    Code:
    header('content-type: text/html; charset: utf-8');
    ini_set('default_charset', 'utf-8');

    Some characters work for me now, it's better than before, but I'm not sure if it works for all users and "& #8220;"/"& #8217;"/ect... (no white space) is still unconverted.

    Does it work for you? How did you check to see what the server was sending? Is there something in cpanel to modify this?

    P.S. I love sitepoint.

  6. #6
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,319
    Mentioned
    462 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by Nination View Post
    However, the characters still do not display correctly.
    Huh, as first it seemed to be be working for me, but when I refreshed, it was back to the previous state. Did you revert back, or is that code still in there?


    Is it sending UTF-8 to the browser yet? How do you check that?
    Each browser has a different way to check it. In Chrome, I open the developer tools, then choose Network, then refresh the page. Then click on the documents option, then click on a site page like the home page and click on the Headers tab on the right. Under Response Headers you'll see the charset being sent from the server.

    charset1.png
    Attached Images Attached Images

  7. #7
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm...all of the code is still there. I did not modify it since my last post.

    The page http://otakuhelpers.com/manga/ seems to be UTF-8
    However, the main page is using "Windows-1252" on Firefox and "ISO-8859-1" on chrome. I'm baffled. lol

  8. #8
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,319
    Mentioned
    462 Post(s)
    Tagged
    8 Thread(s)
    I'm seeing it all as UTF-8 in Chrome and Firefox now. Perhaps do a few page refreshes and check again.

  9. #9
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem was my vbulletin forum sends the wrong character encoding when the page is not cache. Do you know how to make vbulletin send the right encoding and how to fix those other characters converting?

  10. #10
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,319
    Mentioned
    462 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by Nination View Post
    Do you know how to make vbulletin send the right encoding and how to fix those other characters converting?
    I'm afraid I don't, but I'm sure many around here do. If they don't see this thread, perhaps post a vbulletin-specific question in the CMS forum.

  11. #11
    SitePoint Member
    Join Date
    Jul 2013
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


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
  •