1
Dave_L
Newlines
  • 2003/12/24 10:40

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


I'm writing a script to import another forum's database into Xoops.

The other database stores actual HTML line break tags (<br>) in the posts' text.

Should "<br>" be translated to "\n" (Unix line terminator), or to "\r\n" (DOS/Windows line terminator)? Does this depend on whether the server is Linux or Windows?

2
CBlue
Re: Newlines

It's the mysql, that's why you should use the "\n". It doesn't matter if the server is Linux or Windows because I use both types and you need to use "\n" instead of "<br>".

3
Dave_L
Re: Newlines
  • 2003/12/25 0:47

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Thanks

I found this function in class/module.textsanitizer.php. So it looks like it doesn't matter whether \r\n, \r, or \n is used in the database.

/**
     * Convert linebreaks to <br /> tags
     *
     * @param    string  $text
     *
     * @return    string
     */
    
function &nl2Br($text)
    {
        return 
preg_replace("/(1512)|(15)|(12)/","<br />",$text);
    }

Login

Who's Online

127 user(s) are online (80 user(s) are browsing Support Forums)


Members: 0


Guests: 127


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits