Jump to content

contents of Textfile to Image, Strange characters showing


Gulsaes

Recommended Posts

When converting the contents of a text file to an Image inside the text I am seeing strange characters like the character code: 0xDA How would i remove this as i do not see it in the text file

see image below after 23/17.

 

fllsau6.png

 

what would i Put into str_replace to remove this from the text once i've pulled it from the file ?

 

 

 

function CreateImg($field,$filename,$imc_returner)
{    
    $im = imagecreate(600, 30);
    
    $bg = imagecolorallocate($im, 255, 255, 255);
if ($imc_returner == "VMC")
{$textcolor = imagecolorallocate($im, 0, 0, 0);	}
elseif ($imc_returner =="MARGINAL")
{$textcolor = imagecolorallocate($im, 255, 0, 255);	}
elseif ($imc_returner =="IMC")
{$textcolor = imagecolorallocate($im, 255, 0, 0);	}
    
  //  imagefilledrectangle($im, 0, 0, 399, 29, $bg);    
    imagestring($im, 2, 0, 0, $field, $textcolor);
    
    $file = "metar_images/" . $filename . ".png";
    imagepng($im,$file);
    echo "<img src= '$file' />";
}

 

the $field is information i have pulled from a text file so the information is in FLLS.txt if i remove the space inbetween 23/17 and Q1023 in the text file its fine

 

but i want to use the str_replace function to remove that character from the text field $field before the image is displayed, but when i open the txt file I dont see the character only a space, So i have no idea what to put in str_replace

 

 

 

Found a Solution

 

using any of the following would remove the strange characters which turned out to be line feeds CR/LF etc

 

str_replace( array("\r\n","\r","\n") , '<br>' , $subject);

 

Alternatively:

 

str_replace( array("\0x0d\0x0a","\0x0d","\0x0a") , '<br>' , $subject);

 

Alternatively:

 

str_replace( array(chr(13).chr(10) , chr(13) , chr(10)) , '<br>' ,

$subject);

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.