What does "/r" "/n" mean ???:(

liunx

Guest
Thanks a lot<!--content-->I'm assuming you mean \r and \n. If so, they are the codes to add a line break.<!--content-->You mean both of them?<br />
thanks<!--content-->Well, they are a bit different. For example, in PHP, when working with files, \n is the *nix line break, while \r\n is the Windows line break... (Windows likes to be special...) For the most part, \n is what you need. In JavaScript, \n is a line break in an alert, etc...<!--content-->We are using JavaScript to make a Rich Text Format component.<br />
In the RTF,after editing the data, it will be stored in a database,and take it out to show when necessary. well, there is a function to transfer the format of the data before entering the database and after coming out the database. It is like this<br />
<br />
String toHTML(String value) {<br />
if ( value == null ) return "";<br />
value = replace(value, "\r\n","<BR>&nbsp;&nbsp;&nbsp;&nbsp;");<br />
value = replace(value, "\r","<BR>&nbsp;&nbsp;");<br />
value = replace(value, "\n","<BR>&nbsp;&nbsp;");<br />
return value;<br />
}<br />
String toHTMLother(String value) {<br />
if ( value == null ) return "";<br />
value = replace(value,"<BR>&nbsp;&nbsp;&nbsp;&nbsp;", "\r\n");<br />
value = replace(value, "<BR>&nbsp;&nbsp;","\r");<br />
value = replace(value,"<BR>&nbsp;&nbsp;", "\n");<br />
return value;<br />
} <br />
<br />
My question is why they use such a transfer function instead of putting the data directly into the database? And how can "<BR>&nbsp;&nbsp;" take the place of "/r"<!--content-->in HTML, <br> is the line break.<br />
<br />
Also, they probably put it in the database using the \n or <br />
\r line ending as it is more readable while in the DB that way.<!--content-->
 
Back
Top