I have the following entry in the database:

Сдать деньги: -Студент1 -Студент2 -Студент3 -Студент4 До 12.05.2014 

The application that made on Android, displays the same, preserving the formatting .

But at the conclusion of the site goes hat ...

 Сдать деньги:-Студент1-Студент2-Студент3 -Студент4До 12.05.201 

PS I know about htmlentities , but this is not what is needed, because in Android (TextView) everything is fine, why isn’t it normal to the site?

I use PSS via AJAX to accept data and output it to the site in the following form:

 check += "<div id='item_image'><img src='../NImages/"+data[i].Image+"'/></div>"; check += "<div id='item_lower'>"+data[i].LowerText+"</div></div>"; 

data [i] .LowerText is the very text.

    1 answer 1

    I suppose that textView on adnroid accepts line feeds as it should, but for html \ n it doesn’t say anything, you should use <br>. In addition, many consecutive spaces are ignored, transforming into one. Alternatively, you need to process the string from the database before outputting it in html, replacing:

    1. line breaks (\ n, \ r \ n, \ r) on <br>
    2. replace spaces with & nbsp;

    Another option is to put your unformatted text in the tag <pre> http://jsfiddle.net/KRj8w/

    • Thanks, great option. - Man