SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Now available in Orange Tijmen's Avatar
    Join Date
    Jul 2004
    Location
    The Netherlands
    Posts
    1,469
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    · and ' locally changes to ? character online?

    When I tested a website locally the text appeared just fine, with · in front of them or ' in the middle. But now that I have uploaded everything to a demo server the · and ' changed into ? Why does this happen, and what can I do to fix it?

    This is what happens with text thats entered into the database

    PHP Code:
    function safeEscapeString($string){

           global 
    $dbc;
           if (
    get_magic_quotes_gpc()) {
              
    $string stripslashes($string);
            } 
         return 
    mysql_real_escape_string($string$dbc);    
         
    }
      
    function 
    cleanVar($string){

          
    $string trim($string);
          
    $string safeEscapeString($string);
          
    $string strip_tags($string);
          
    $string preg_replace('/\s\s+/',' '$string); //double spaties
          
    return $string;
          

    I thought maybe I should have used htmlspecialchars for the ·, but that doesn't have any effect.
    Travel Photos on Flickr - Twitter

    “Never give up. Never surrender”

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sounds like your web server is declaring a different character encoding (in the Content-Type HTTP header) than you used when editing your files.
    Birnam wood is come to Dunsinane

  3. #3
    Now available in Orange Tijmen's Avatar
    Join Date
    Jul 2004
    Location
    The Netherlands
    Posts
    1,469
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jup, server uses UTF-8 which I didn't use. But it doesn't seem to have any effect, I changed the files to UTF-8 now and nothing changed.

    Using Live Headers in Firefox I get this

    Code:
    Content-Type: text/html; charset=UTF-8
    But a bit further up it also says this, which tell me both of them are supported?
    Code:
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Travel Photos on Flickr - Twitter

    “Never give up. Never surrender”

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Tijmen View Post
    Jup, server uses UTF-8 which I didn't use. But it doesn't seem to have any effect, I changed the files to UTF-8 now and nothing changed.
    What do you mean by 'I changed the files to UTF-8'?
    Did you re-save the files as UTF-8 and upload them to your server?

    If you just changed your <meta> tag you haven't really changed anything. You need to save the files as UTF-8, or tweak the server to declare the encoding you actually did use.

    By 'save the files as UTF-8' I mean that you must change the encoding setting in your editor to UTF-8 and then save the files again.

    Quote Originally Posted by Tijmen View Post
    Using Live Headers in Firefox I get this

    Code:
    Content-Type: text/html; charset=UTF-8
    But a bit further up it also says this, which tell me both of them are supported?
    Code:
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    That's Firefox telling the server which encodings it supports. It says that it prefers ISO-8859-1, but will accept UTF-8 if it has to and will try to take on anything else, too.

    I doubt that you have any negotiation for character encoding on your site, so this header will most likely be ignored.
    Birnam wood is come to Dunsinane


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
  •