TextView carriage return not working

I am reading a line from an xml file stored on an SD card that has some carriage returns stored with the escape sequence "\ n". For instance,

<string mystring="Line1\nLine2">

But when I show the text in the emulator, \ n appears instead of creating a new line. I am not doing anything unusual in the text, just reading it with SAXParser and then adding it to the text box. Is there a parameter that I need to check to make sure the newlines are displayed correctly? Do I need to save the carriage differently in the xml file?

I tried \ r \ n too, and this does not work either. When I debug, I see that an extra \ is placed in front of the existing \ I see that in my startElement SAX method, the line

String s = atts.getValue("mystring");

assigns "Line1 \ nLine2" to s, so the problem is with SAXParser.

+3
source share
4 answers
&#xA;

works very well in the middle of the quoted text. I would like to add that in the Eclipses graphics tool it fits in extra space (for example, it has double explode). However, when it compiles and you run it on an emulator or device, you only have a carriage return. So, trust MrGibbage and you will save time.

+4
source

\nis actually a linefeed, and a carriage return is \r. Try using both together, for example. \r\n.

Read more about newline .

To handle spaces with SAX, consider a method ignorableWhitespace(..).

+3

, . XML ampersand-hash-x-A-semicolon

&#xA;
+2

Use &#10;where you need a curry return.

+1
source

Source: https://habr.com/ru/post/1536654/


All Articles