KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Alternative use of the 4D HTML Tag "#4DHTML"
PRODUCT: 4D | VERSION: 13.3 | PLATFORM: Mac & Win
Published On: September 14, 2013

A common task when replacing including text stored in 4D into a web page is to account for line endings so that text break appear the same on the web page as they do when displayed in a text block within 4D.

The problem is that there are three possible line endings that will need to be accounted for...


  • Window -- Carriage Return plus Line Feed (\r\n)

  • UNIX -- Line feed (\n)

  • Macintosh -- Carriage Return (\r)



   // Take care of possible line endings in the block of text
   // and replace with the HTML break tag
   //
C_TEXT(TEXT_Buffer_T)
TEXT_Buffer_T:=Replace string([MyTable]MyText;"\r\n";"<br>")   // Windows CRLF
TEXT_Buffer_T:=Replace string(TEXT_Buffer_T;"\n";"<br>")   // Unix new line
TEXT_Buffer_T:=Replace string(TEXT_Buffer_T;"\r";"<br>")   // Mac carriage return


To account for the html markup that has been inserted into the text, the 4D HTML Tag "#4DHTML" will have to be used instead ot the tag "#4DTEXT" so that the html tag "<br>" will not translated into unicode representations.

<div class='myDetail'><!--#4DHTML TEXT_Buffer_T--></div>