Gulsaes Posted November 20, 2008 Share Posted November 20, 2008 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. what would i Put into str_replace to remove this from the text once i've pulled it from the file ? Quote Link to comment https://forums.phpfreaks.com/topic/133473-contents-of-textfile-to-image-strange-characters-showing/ Share on other sites More sharing options...
Adam Posted November 20, 2008 Share Posted November 20, 2008 Can we see some code? How are you converting to the text to an image? What does the text originally look like? "0xDA" looks like hexadecimal .. http://en.wikipedia.org/wiki/Hexadecimal Adam Quote Link to comment https://forums.phpfreaks.com/topic/133473-contents-of-textfile-to-image-strange-characters-showing/#findComment-694203 Share on other sites More sharing options...
Gulsaes Posted November 20, 2008 Author Share Posted November 20, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/133473-contents-of-textfile-to-image-strange-characters-showing/#findComment-694213 Share on other sites More sharing options...
Gulsaes Posted November 25, 2008 Author Share Posted November 25, 2008 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); Quote Link to comment https://forums.phpfreaks.com/topic/133473-contents-of-textfile-to-image-strange-characters-showing/#findComment-698523 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.