fixAwkwardEntities

Mr. T’s recent “Would you like to…” post displayed terribly on the main page, but was properly-formatted on his page.

I’ve (*crosses fingers*) fixed it… For some reason, both Firefox and IE throw up an error ’symbol’ when they encounter a character with an ASCII value over 128… They normally look better, except for when browsers don’t display them…

So I whipped this together:

        for($i=0; $i<strlen($text); $i++) {
                $val = ord($text[$i]);
                if ($val < 128) $return .= $text[$i];
                else $return .= ("&#" . $val . ";");
        }

Essentially, if a character has an ASCII value over 128 (which means it’s one of the ‘weird ones’ that causes problems on some systems), it gets converted to the { syntax, which means it displays properly. And so far, so good!


  • No Related Post
bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark
tabs-top


2 Comments »

  1. andrew says:

    IIRC, I noticed that if I changed my character encoding to ISO-8859-1 (”Western” in Firefox), that his quotes showed up fine. The main page explicitly specifies UTF-8 encoding, so it may just be mismatched encodings.

  2. Matt says:

    That’s what mine defaults to on Windows, actually.

RSS feed for comments on this post. TrackBack URL

Leave a comment