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!

2 thoughts on “fixAwkwardEntities

  1. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *