开发者

HTML Characters and []'s in Dynamic Image

I am making a dynamic image that parses off of an rss feed. When I do开发者_开发技巧 the parsing normally, it displays exactly as I want it to, but when I put it in the image, there are boxes and html characters like ' aren't actually apostrophes.

Here's a link to my image as of right now (with boxes): http://img.got-skills.net/advlog/advlogmaker.php?user=Judgment001

Halp pl0x.


The boxes are likely to be characters which the font you're using does not provide. Without seeing your code it's a bit difficult to tell where you're going wrong, but I would imagine you could benefit from judicious use of the following:

  1. http://php.net/manual/en/function.htmlspecialchars-decode.php (PHP >= 5.1)
  2. http://php.net/manual/en/function.html-entity-decode.php

You may also need to trim your strings prior to writing them to the image, to get rid of extraneous tab characters etc. You may even need to provide additional characters to trim (second argument) in order to cover extended characters embedded in the RSS feed.


I'd check the font and the encoding for your text. If you can supply more info (like some of the code you're using) that would help.


You can just use regex to remove all the non safe characters like so:

/**
 * GetFilenameSafeString()
 * 
 * @global Returns a filename that is save for the OS to save
 * @param string
 * @return string 
 */
    function GetFilenameSafeString ( $filename )
    {
        // convert spaces to an underscore
        $filename = preg_replace("/\s+/", "_", $filename);
        // remove all non qwerty characters
        $filename = preg_replace("/([^a-zA-Z0-9_!@#\$%\^&\(\)\[\]\-]+)/", "", $filename);
        return $filename;
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜