Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2007
    Location
    Denver, CO
    Posts
    27

    Black diamond question mark

    Hi,

    I've come across a few of my sites on the server at my work that are showing up with Black Diamonds with question marks in them. It seems like just recently have we started having this problem, sites that have been up for a while now without these problems are now having them. What could be the cause of this so that we may look into it?

    Thanks.
    Derek Keith
    Indesicant Designs / Owner
    http://www.indesicant.com

  2. #2
    Join Date
    Apr 2007
    Location
    Denver, CO
    Posts
    27
    Also as far as I know the servers are ubuntu linux, and the charset is UTF-8. In IE it just shows an empty square, in firefox a black diamond with a white question mark...
    Derek Keith
    Indesicant Designs / Owner
    http://www.indesicant.com

  3. #3
    Join Date
    Aug 2001
    Location
    Central USA
    Posts
    200
    You're on the right track - It's a character-set issue. Get a tool that inspects the response headers of the server (like the Firebug extension if you're using Mozilla Firefox) to see what character set the server response is sending with the content. If the server's character-set and the HTML character set of the actual content don't match up, you will see some strange looking characters like those little black diamond squares.
    InvoiceMore - Online Billing & Invoicing
    phpDataMapper - Object-Oriented PHP5 Data Mapper ORM

  4. #4
    Join Date
    Aug 2001
    Location
    Central USA
    Posts
    200
    Also, I just dug up this website you will want to look at:
    http://www.phpwact.org/php/i18n/charsets
    InvoiceMore - Online Billing & Invoicing
    phpDataMapper - Object-Oriented PHP5 Data Mapper ORM

  5. #5
    Join Date
    Apr 2007
    Location
    Denver, CO
    Posts
    27
    I appreciate the help, I haven't had a chance to look at it as I've been busy with some other various work, but as soon as I get a chance i'll try it out. You've been pretty helpful and you've given about the only sensible advice. Everyone else insists on it being the files themselves, but i'm almost positive that it's a server issue.
    Derek Keith
    Indesicant Designs / Owner
    http://www.indesicant.com

  6. #6
    Join Date
    Oct 2004
    Location
    Southwest UK
    Posts
    1,175
    moved to tech issues
    Do not meddle in the affairs of Dragons, for you are crunchy and taste good.

  7. #7
    Join Date
    Nov 2001
    Location
    Vancouver
    Posts
    2,422
    Its definitely a character set issue.

    See this thread where I post a quick set of things you can try, and links for learning:

    http://www.webhostingtalk.com/showthread.php?t=621254
    “Even those who arrange and design shrubberies are under
    considerable economic stress at this period in history.”

  8. #8
    Hi, Derek
    What you're looking at is the result in the difference in what character set your browser is interpreting, versus the character set originally typed into the form, saved in the database, or saved on the page. In other words, there's a discrepency in "charset". Below, I provide a checklist that should help in most situations.

    I know when I first saw the black diamond with question mark, I was using a research tool I had created, which includes a script to pull and print some lines from another site. There were sometimes numerous "Windows" special characters in the page code of other sites. When I changed my Safari browser from default (which was set at UTF-8) to Western ISO Latin 1, the text was normalized; and I could read it.

    That was a short-term, immediate fix. Of course, I, like you, needed a long term, permanent solution.

    It's possible, as you thought, that the "wrong signals" are being sent by the server; but you should be able to correct this if you have control of the scripts on the server. More on that below.

    Here is a checklist:
    ---------------------
    1. TEXT FILES, SAVE AS: If you are uploading any pages to the server, you should make sure the page content is SAVED AS (option) Unicode (UTF-8, no BOM), rather than the default (probably Latin1). The UTF-8 BOM causes a lot of problems at this time (especially in PHP); so output _without_ the BOM.

    2. DYNAMIC SCRIPT: script output:

    PERL: Instead of the requisite line,
    print "Content-type: text/html\r\n\r\n";
    use the following line:
    print qq|Content-type: text/html; charset="utf-8"\r\n\r\n|;

    PHP: Output this header before content output:
    header("Content-type: text/html; charset='utf-8'");

    3. HTML: On any html pages output by a script, or by a WYSIWYG editor, or rolled by hand, add the meta tag "charset" identifier before opening the title tag. In fact, it should be the first meta tag after the head tag is opened. This method is suppose to force the browser to reparse everything if it wasn't parsing in that character set in the first place. (However, I can't validate that.) In other words, do this:

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    4. XML/XHTML: With XML pages, declare the "charset" in the opening line, like:
    <?xml version="1.0" encoding="utf-8"?>
    In xhtml documents, I still add in the meta tag from tip #3, above, for good measure.

    5. FORM: To assist with properly encoded form input from your guests and members, use the "accept-charset" form attribute, like this:
    <form method="post" accept-charset="utf-8">

    6. DATABASE: Finally, you may want to set your database default character set to utf-8 if you are storing utf-8 input.

    Fran Corpier

  9. #9

    Arrow Found a fix

    I know this post is REALLY old, but this funky question mark diamond character has been driving me crazy all night. I finally found a solution to it.

    First off, I was getting this character when I was uploading a tab delimited file using PHP. The file itself is from Google's Adsense reporting. Google has labelled the downloaded file as a CSV file, though it is actually a tab-delimited values file versus a comma separated values file. Anyway, I wanted to save the file to my desktop, then upload it to my web site via a PHP script and store the data in a MySQL database.

    The simple fix (in PHP):

    PHP Code:
      $file "path_to_file.csv";
      
    $fh fopen($file'rb'); /* 'rb' is to read a binary file on a Windows system */
      
    $line fread($fhfilesize($file));
      
    $old = array("\n""\r\n""&#10""&#09""%09""%20""\0");
      
    $new = array("""""""&nbsp; &nbsp; "","" """);
      
    $l nl2br($line);
      
    $l2 explode("<br />"$l);
      foreach (
    $l2 as $k => $v){
        if (!empty(
    $v)){
          if ((
    stristr($v"D") === FALSE) && (stristr($v"T") === FALSE) && (stristr($v"A") === FALSE)){
            
    $full str_replace($old$new$v);
            
    $data explode("\t"trim($full));
            if (
    stristr($data[0], "/")){
              
    insert_adsense_line($data[0], $data[1], $data[2], $data[3], $data[4], $data[5]);
            }
          }
        }
      }
      
    fclose($fh); 
    I know this code is a bit sloppy, but hey, I've been up for 17 hours working on this damn thing...I will clean up my script tomorrow...

    The important thing here is the $old array. In it, you will see the last string "\0". That is a zero, not a capital O. It was this character that was causing the issue. Once I replaced "\0" with "" (a blank no-character string), the funky question mark disappeared and the file is being processed as I need it to.

    Additionally, I made sure that my database table is set to utf8_bin.

    I hope this helps!

  10. #10

    Question Nice one

    Many thanks for sharing the solution




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •