tags:

views:

44

answers:

3

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.

+1  A: 

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.

Alex JL
+2  A: 

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.

EloquentGeek
A: 

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;
    }
TravisO