Each OS have different ASCII chars for linebreak:
windows = \r\n
unix = \n
mac = \r
And nl2br doesn't work with \r\n in my system !
nl2br("blabla\r\nblabla") outputs "blabla<br />\r\n" !!
As nl2br is called 2 times sometime (when new task is created), \r\n are converted in two <br/> !
I suggest to define a new method in system called string2html (or whatever you want) that do
return str_replace(array("\r\n", "\n", "\r"), "<br />",$str)
And replace all nl2br with this function.
One can use a more complex method to integrated bbcode for example later...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think there are 3 forms for text, some could be the same but there are différent:
1) text rendered on html page (with html tags)
2) text writen by users in a form
3) text inside database
Here an example for CR and image
1) text has <br/> or <p/>, and <img...> for example
2) text has \r\n or \n depends of system, and [img] in bbcode style
3) text could persist as \\n and [img] (same as 2 here)
or as <br/> and <img...> (like 1)
We must determine wich class or php do the conversions...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Nexty use :
- nl2br
- str_replace('\r\n',
- mysql_real_escape_string
- escapeQuery/unescapeQuery
Each OS have different ASCII chars for linebreak:
windows = \r\n
unix = \n
mac = \r
And nl2br doesn't work with \r\n in my system !
nl2br("blabla\r\nblabla") outputs "blabla<br />\r\n" !!
As nl2br is called 2 times sometime (when new task is created), \r\n are converted in two <br/> !
I suggest to define a new method in system called string2html (or whatever you want) that do
return str_replace(array("\r\n", "\n", "\r"), "<br />",$str)
And replace all nl2br with this function.
One can use a more complex method to integrated bbcode for example later...
I think there are 3 forms for text, some could be the same but there are différent:
1) text rendered on html page (with html tags)
2) text writen by users in a form
3) text inside database
Here an example for CR and image
1) text has <br/> or <p/>, and <img...> for example
2) text has \r\n or \n depends of system, and [img] in bbcode style
3) text could persist as \\n and [img] (same as 2 here)
or as <br/> and <img...> (like 1)
We must determine wich class or php do the conversions...