tox_yray Posted August 11, 2006 Share Posted August 11, 2006 Hi, See, I have this massive chunk of code to convert RTF into HTML and I get problems with special characters when their is "something" (other than a space) between the special character and the rest of the word. For example, the flow "\'c9cole Polytechnique de Montr\'e9 al \par." seems to have only a space between the last "é" and "al" and between "al" and "\par" too. However, when I mark, nl2br() and explode the string, here is what is returned on screen: [code]2078: $$!!CONTROL++--++SPACECHARc92079: cole2080: Polytechnique2081: de2082: Montr2083: $$!!CONTROL++--++CHARe92084: al.2085: $$!!CONTROL++--par[/code]As you can see, <br>s were introduced before and after "al", which means there is a \n and/or \r char there, that I an't see when I print the stream with echo.My goal now is to detect those characters to delete them from the RTF stream I have to interpret. How to do it is where I hit a wall. Any ideas how to do this?Thanks a lot for any input,Bruno M-A. Link to comment https://forums.phpfreaks.com/topic/17242-deleting-hidden-control-chars-n-r-t-etc-from-a-rtf-stream-fixed/ Share on other sites More sharing options...
effigy Posted August 11, 2006 Share Posted August 11, 2006 Use the "\r" and "\n" in str_replace. Link to comment https://forums.phpfreaks.com/topic/17242-deleting-hidden-control-chars-n-r-t-etc-from-a-rtf-stream-fixed/#findComment-73086 Share on other sites More sharing options...
tox_yray Posted August 11, 2006 Author Share Posted August 11, 2006 Thanks a lot, it works like a charm. However, for future reference, you have to make sure you write your search array like this:[code]$search = array("\r", "\n");[/code]Escaping the slash (\\) will cause the script to search for the actual string "\r" instead of the char '\r'.Single quotes will auto-escape the slash, so double quotes are required here.Hoping this will help more people around here sometime,Bruno M-A. Link to comment https://forums.phpfreaks.com/topic/17242-deleting-hidden-control-chars-n-r-t-etc-from-a-rtf-stream-fixed/#findComment-73130 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.