197
Views
3
Comments
Insert a new line in a database text attribute
Question

Is there a way to represent a new line in a database text attribute?

  • In the text area I can create the new lines, save it and the database always return the text like this:
  • But in the database it shows only separated by a white space without reference to the char/command that creates the new line.

Thanks

2018-10-29 08-31-03
João Marques
 
MVP

Hi José,


I think it depends on the database you are using. In SQL Server, these ones are identified by the CHAR(13) and the CHAR(10), like explained here.

In any case, you can expand the functionality in a WYSIWYG and ease of use by using the CK Editor, which saves the information as HTML. I think this is the standard today, and using the component makes it pretty easy.


Kind Regards,
João

2021-04-17 09-53-48
José Gonçalves

I need the instruction to break line already in the text attribute. CHAR(10), etc, only works outside the database.

CK Editor is not an option because I need to have already the text broken in lines (data coming from migration) and display it in a text area.

2018-10-29 08-31-03
João Marques
 
MVP

Hi José,


You can always do some pre / post processing turning the newlines into the database format before putting in the database / after fetching it from the database.

As for the CK Editor, there are ways of converting text into HTML, but then again, you know best the use case.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.